Processing Run-time Errors

GT.M does not detect certain types of errors associated with indirection, the functioning of I/O devices, and program logic until run-time. Also, the compile-as-written feature may leave errors which GT.M reports at run-time when it encounters them in the execution path. At run-time, GT.M reports any error encountered to stderr. The run-time system suspends normal execution of the routine as soon as it detects an error.

GT.M responds to errors differently depending on whether it encounters them in Direct Mode (at the command line) or during normal program execution.

When an executing GT.M image encounters an error:

After the action, if any, invoked by $ETRAP, $ZTRAP or EXCEPTION:

Run-time Errors in Direct Mode

When GT.M detects an error in Direct Mode, it reports the error with a message and leaves the process at the GTM> prompt.


%GTM-E-INVCMD, Invalid command keyword encountered

In Direct Mode, GT.M provides access to the RECALL command. RECALL allows you to retrieve a Direct Mode command line with a minimum of typing. A GT.M line editor allows you to make quick changes or corrections to the command line. For more information on RECALL and the line editor, see Chapter 4: “Operating and Debugging in Direct Mode.

Run-time Errors Outside of Direct Mode

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".

[Note] Note

The environment variable gtm_etrap specifies an initial value of $ETRAP to override the default value of "B" for $ZTRAP as the base level error handler. The gtmprofile script sets gtm_etrap to "Write:(0=$STACK) ""Error occurred: "",$ZStatus,!" which you can customize to suit your needs. For more information, refer to “Processing Errors from Direct Mode and Shell.