Chapter 13. Error Processing

Revision History
Revision V7.1-004 27 June 2024
Revision V7.1-002 19 September 2023
Revision V7.1-001 26 June 2023
Revision V7.0-002 23 March 2022
Revision V6.3-007 04 February 2019
Revision V6.3-005 29 June 2018
Revision V6.3-003 12 December 2017
Revision V6.3-001 20 March 2017
Revision V6.0-003 24 February 2014

In “Run-time Errors Outside of Direct Mode”, added a note about the gtm_etrap environment variable.

Revision V6.0-001 21 March 2013

In Choosing $ETRAP or $ZTRAP”, added a note about handling non-fatal errors.

Table of Contents

Compile Time Error Message Format
Processing Compile Time Errors
Run-time Error Message Format
Processing Run-time Errors
Run-time Errors in Direct Mode
Run-time Errors Outside of Direct Mode
Program Handling of Errors
$ECODE
$ZSTATUS Content
$ZERROR and $ZYERROR
$ETRAP Behavior
Nesting $ETRAP and using $ESTACK
$ZTRAP Behavior
Differences between $ETRAP and $ZTRAP
$ZTRAP Interaction With $ETRAP
Choosing $ETRAP or $ZTRAP
Error Processing Cautions
Input/Output Errors
Error Actions
Break on an Error
Unconditional Transfer on an Error
Setting $ZTRAP for Each Level
Nested Error Handling
Terminating Execution on an Error
Setting $ZTRAP to Other Actions
Summary of $ETRAP & $ZTRAP Error-Handling Options
Errors in $ZTRAP
Recording Information about Errors

This chapter describes GT.M features and techniques for handling errors. Errors in programs may be classified as "predictable" meaning foreseen, or "unpredictable" meaning unforeseen.

M programs may attempt to recover from predictable errors. Device errors that can be remedied by an operator are the most common class of errors for which recovery provides a large benefit. Predictable errors from which the program does not attempt to recover are generally treated the same as unpredictable errors.

A typical application handles unpredictable errors by logging as much information about the error as the designer considers useful, then terminating or restarting the application from a known point.

Because GT.M invokes error handling when things are not normal, careful design and implementation of error handling are required to minimize the impact of errors and the cost of subsequent prevention.

The GT.M compiler detects and reports syntax errors at:

The GT.M run-time system: