Condition handling
While a PL/I program is running, certain events can occur for which you can do some testing, issue a response, or take recovery action. These events are called conditions, and are raised when detected.
Conditions can be unexpected errors (for example, overflow, input/output transmission error) or expected errors (for example, end of an input file). Conditions can be raised directly in a program through the SIGNAL statement (this can be very useful during testing).
Application control over conditions is accomplished through the enablement of conditions and the establishment of actions to be performed when an enabled condition is raised. When a condition is disabled, the compiler assumes that the condition cannot occur and generates code accordingly. If the condition does occur, your program is in error. The established action can be an ON-unit or the implicit action defined for the condition.
When an ON-unit is invoked, it is treated as a procedure without parameters. To help you use ON-units, built-in functions and pseudovariables are provided for you to inquire about the cause of a condition. Pseudovariables are often used for error correction and recovery.
The implicit action for many conditions is to raise the ERROR condition. This provides a common condition that can be used to check for a number of different conditions, rather than checking each condition separately. The ONCODE built-in function is particularly useful here, as it can be used to identify the specific circumstances that raised the conditions. Codes corresponding to the conditions and errors detected are listed in Messages and Codes.