The instructions to set a trap for errors are SIGNAL and CALL. Example formats are:
SIGNAL ON condition NAME trapname CALL ON condition NAME trapname
The SIGNAL ON instruction initiates an exit subroutine that ends the program. The CALL ON instruction initiates a subroutine that returns processing to the clause immediately following the CALL ON instruction. Use CALL ON when you want to recover from a command error or failure.
The two command conditions that can be trapped are:
ERROR
A failure, in this sense, is a particular category of error. If you use SIGNAL ON or CALL ON to set a trap only for ERROR conditions, then it traps failures as well as other errors. If you also specify a FAILURE condition, then the ERROR trap ignores failures.
With both the SIGNAL and CALL instructions, you have the option of specifying the name of the trap routine. Add a NAME keyword followed by the name of the subroutine. If you don't specify the name of the trap routine, REXX uses the value of condition as the name (REXX looks for the label ERROR:, FAILURE:, and so on).
For more information about other conditions that can be trapped, see the Object REXX Reference.