Tracing exceptions

Exception can be logged in a file when using the STARTLOG() function.

Exceptions are automatically logged in a file, if all the following conditions are true:

  • The STARTLOG function has been previously called to specify the name of the exception logging file.
  • The exception action is set to CALL, GOTO or STOP. Exceptions are not logged when the action is CONTINUE or RAISE.
  • The exception class is an ERROR, ANY ERROR or WARNING. NOT FOUND exceptions cannot be logged.

In other words, errors will not be logged in the case of WHENEVER { [ANY] ERROR | WARNING } CONTINUE, or when controlled by a TRY/CATCH block.

Each log entry contains:

  • The system-time
  • The location of the related instruction (source-file, line)
  • The error-number
  • The text of the error message, giving human-readable details for the exception

It is good practice to generate the call stack trace with the base.Application.getStackTrace() function, typically in the handler used WHENEVER ERROR CALL my_handler().