Summary of $ETRAP & $ZTRAP Error-Handling Options

Summary of Error-Handling Options

ERROR-HANDLING FEATURE

DESCRIPTION AND POSSIBLE USES

$ETRAP="BREAK"

$ZTRAP="BREAK"

Returns to Direct Mode upon encountering an error that enables interactive debugging to determine the nature of the error.

$ETRAP="GOTO.."

$ZTRAP="GOTO.."

Transfers control upon encountering an error and allows for continuation of execution after the error. Use with an error handling routine that may record or report an error.

$ETRAP="ZGOTO.."

$ZTRAP="ZGOTO.."

Similar to GOTO, but additionally allows for removal of levels from the stack. Use to allow recovery to specific point, such as a menu.

NEW $ETRAP

NEW $ZTRAP

Stacks the old value of $ETRAP or $ZTRAP and sets the new value to the empty string. Usually followed by a SET $ETRAP or SET $ZTRAP. After a QUIT from a given level, GT.M restores the value held prior to the NEW. Use to enable different methods of error handling at different levels within an application.

$ETRAP="DO..."

Transfers execution temporarily to another label upon encountering an error. After return from a DO, GT.M QUITs from the stack level at which the error occured. Whether control returns to the invoking code or to the trap handler at the less nested level, depends on the value of $ECODE.

$ZTRAP="DO..."

Transfers execution temporarily to another label upon encountering an error. When GT.M returns from a DO and completes the $ZTRAP action, execution continues at the beginning of the line containing the error and re-executes the entire line containing the error. Use with I/O device errors where operator may intervene to correct the error condition.

$ZTRAP=""

Returns to DCL with the Status Code and terminates execution. If SET in error handling routines, prevents infinite loops. Prevents access to Direct Mode. Use in production code when the invoking DCL needs to test $Status.

$ETRAP="SET $ECODE="""""

$ZTRAP="QUIT"

Terminates execution at that level upon encountering an error, and returns to the invocation level at the point immediately following the invocation. Use to ignore errors on a particular level and continue executing.

$ZTRAP="HALT"

Returns to DCL as if normal termination occurred. Avoids access to Direct Mode. Use in production code when the invoking DCL does not need to examine the exit status of the GT.M process.