$ET[RAP] contains a string value that GT.M invokes when an error occurs during routine execution. When a process is initiated, GT.M assigns $ETRAP the value of the gtm_etrap environment variable, if gtm_etrap is defined, and otherwise the empty string, in which case $ZTRAP="B" controls initial error handling.
The value of this variable is the M[UMPS] code that GT.M executes when it encounters an error.
SET $ETRAP="QUIT:$ESTACK GOTO LABEL^ROUTINE"
The value of $ETRAP is changed with the SET command. Changing the value of $ETRAP with the SET command initiates a new trap; it does not save the old trap.
$ETRAP may also appear as an argument to an inclusive NEW command. NEW $ETRAP causes GT.M to stack the active condition handler's ($ETRAP) old value. NEW leaves the $ETRAP unchanged regardless of the previously active condition handler. NEW $ETRAP command puts $ETRAP in control for error handling.
For more examples of the use of special variable $ETRAP, see the function $STACK().