The following example shows how a program might use SIGNAL ON to trap a command error in a program that copies a file. In this example, an error occurs because the name of a nonexistent file is stored in the variable File1. Processing jumps to the clause following the label ERROR:
/* example of error trap */
signal on error /* Set the trap. */
.
.
.
┌─── "COPY" file1 file2 /* When an error occurs... */
│ .
│ .
│ exit .
└───error: /* ...REXX jumps to here */
say "Error" rc "at line" sigl
say "Program cannot continue."
exit /* and ends the program. */