Unexpected Error Trapping

The EUS Toolkit provides a convenient method for handling unexpected errors, using the same logic as the normal message processing routines.

The developer only needs to provide an entry point for the _unerr.utl program and pass the appropriate information. _unerr.utl then buffers and stacks this error information for later processing by _saywarn.utl.

For example:

SETERR ERRTRAP
LET BBEXT$=STBL("BBEXT")

ERRTRAP:
CALL BBEXT$+"_unerr.utl",ERR,TCB(5),PGM(-2),TCB(10);
RETRY

Assuming that the error was !ERROR=0, the program error occurred at line 2120, and the program was named GLMAIN, then the generated error message would look like the following (when later displayed through _saywarn.utl):

Unexpected error: 0
File or device busy
at line 2120 in module GLMAIN

Errors are maintained in the global string (#LAST_ERROR) in the format:

"ERR=0 LINE=2120 MODULE=GLMAIN TCB(10)=1"

If an OUT OF MEMORY error (!ERROR=33) is reported, _unerr.utl attempts to free more memory by dropping all public programs and setting the global string (LEAN_MEMORY). Applications should check for the existence of the (LEAN_MEMORY) global string before doing anything that could use a large amount of memory, such as CALLing large subprograms. For example, if TAOS sees this global string, it changes its behavior to chain between modules using STARTs rather than nested CALLs.

Certain errors, such as !ERROR=200, are EUS Toolkit internal errors and are reported as "Application Subroutine Error."