Previous
Previous
 
Next
Next

Trapping an Error

To make sure the program works correctly, anticipate errors and set up a system for handling them. You can use a TRAP statement to turn on an error-trapping mechanism in a program. When error trapping is on and an error is signaled, then the execution of the program is not halted. Instead, error trapping does the following:

  1. Turns off the error-trapping mechanism to prevent endless looping in case additional errors occur during the error-handling process

  2. Branches to the label that is specified in the TRAP statement

  3. Executes the statements following the label