Branching to error-handling subroutines
The REXX SIGNAL
ON ERROR instruction tells REXX to leave the current line and branch to
a label marked
error when a nonzero return code is
This statement requires two parts:
- SIGNAL ON ERROR instruction
After every command, REXX puts the return code of the command in a variable called rc.
If a command has a nonzero return code, REXX branches to the
SIGNAL ON ERROR returns errors from the QMF REXX procedure (ADDRESS QRW) command environment, but not the REXX callable interface.
- Error labelThe SIGNAL ON ERROR instruction requires that you provide a label that the procedure can branch to if it encounters a nonzero return code. The label precedes your error handling code. The return code is in the variable rc. You can use this variable to branch to another subroutine, or you can use it in your EXIT instruction, as in the following example:
/* error handling code for a procedure with logic */ error: exit rc