If GT.M encounters an error outside of code entered in Direct Mode, GT.M executes the $ETRAP or $ZTRAP special variable, if either of them have a length greater than zero, which only one can have at a given point in time.
The $ETRAP and $ZTRAP special variables specifiy an action that GT.M should perform when an error occurs during routine execution. $ETRAP and $ZTRAP can establish one or more error handling "actions".