Skip to content

Exception Handling Facilities

Exception Handling Facilities

The GT.M exception trapping allows you to do the following:

  • DO a recovery routine and resume the original command stream.
  • GOTO any special handling; an extended ZGOTO provides for context management.
  • Report an error and enter Direct Mode for debugging.
  • OPEN Input/Output devices with specific traps in addition to the main trap.
  • Trap and process an exception based on a device error.
  • Trap and process an exception based on terminal input.

The following table summarizes the GT.M language extensions that facilitate exception handling.

GT.M Exception Handling Extensions
EXTENSIONEXPLANATION
ZGotoRemoves zero or more levels from the M Invocation stack and, optionally, transfers control.
ZMessageSignals the specified condition.
$ZCSTATUSHolds the value of the status code for the last compile performed by a ZCOMPILE, ZLINK or auto-ZLINK.
$ZEOFContains indication of whether the last READ reached end-of-file.
$ZMessage()Translates an error condition code into text form.
$ZLevelContains current level of DO/XECUTE nesting.
$ZStatusContains error condition code and location of last exception condition occurring during routine execution.
$ZSYstemContains the status code of the last ZSYSTEM.
$ZTrapContains an XECUTE string or entryref that GT.M invokes upon encountering an exception condition.
EXCEPTIONProvides a deviceparameter specifying an XECUTE string or entryref that GT.M invokes upon encountering a device-related exception condition.