When a Rexx program is executed, normally the flow of execution is determined by the program's instructions. However, during the course of processing, various exceptional conditions can arise.
An exception is handled in one of three ways (earlier in the program):
The Rexx language defines the following condition categories.
If a condition handler (CALL ON or SIGNAL ON) was not active when a HALT or SYNTAX error condition occurs, program is concluded. Appropriate error messages are displayed.
If a condition handler (CALL ON or SIGNAL ON) was not active when any other error conditions described above occur, the program continues to operate as though an error did not occur.
When a trap label receives control as a consequence of an error condition, information describing the situation is available by using the condition built-in function. For ERROR and FAILURE conditions, the special RC variable contains the associated command completion code. When SYNTAX conditions occur, the special RC variable contains the associated syntax error number.
The special SIGL variable contains the source line number of the instruction associated with the error condition.
Note: in some implementations you can invoke a program editor when a SYNTAX error occurs. The SIGL value is passed to the editor. The editor can automatically position, and highlight, the source line associated with the error.
Note: there are various additional considerations regarding the handling of error conditions, that are described in TRL-2. For example, conditions can be delayed while a CALL ON handler is processing a condition. These additional considerations are beyond the scope of this tutorial.
The information presented in this tutorial should be satisfactory for most of the condition handling scenarios you will encounter during your Rexx programming endeavors.