DataBasic Exception Handler

The exception handler deals with DataBasic errors within external user functions, subroutines, code structures and DataBasic objects. It operates by informing the run-time system of the location of application code that it should transfer control to if an error occurs (this is handled by the ECATCH statement).

An exception can be generated by the system, or by the user via the ETHROW statement. Exceptions are not limited to local code but could be generated in another section of the application such as an external user function or a local or external subroutine.

Also, if an exception occurs deeper in the code level return stack, the exception handler will automatically return through the levels until a level is reached with a defined exception catcher. This exception catching application code can then decide to handle the exception or pass it to an earlier level and its defined exception catcher.

Exceptions are local to a single program. External code executed as a result of a PERFORM, trigger or English conversion cannot pass exceptions to the program that caused them to be invoked.

Statements

ECATCH - Define exception handler

ECLEARCATCH - Remove exception handler

ETHROW - Generate user exception

ERETHROW - Pass exception back to earlier code level

EDEBUG - Pass exception to DataBasic debugger

Functions

EXCEPT.NUM - Get exception number

EXCEPT.MSG - Get exception message

EXCEPT.STK - Get exception code level return stack

ECATCH.LOC - Exception handler defined in this code level

ECATCH.ACTIVE - Total number of exception handlers defined

See also

Example of Usage