You should be familiar with the following error handling concepts when you attempt to debug your PL/I programs. For details on condition handling, see the PL/I Language Reference.
The operating system offers error-handling facilities. Various situations can cause a machine interrupt, resulting in an entry to the system supervisor. The PL/I control program can use specified routines to define the action that is taken after any of these interrupts. Alternatively, the PL/I control program passes control to ON-units specified by the PL/I programmer.
The PL/I language and its execution environment extend the error-handling facilities offered by the operating system. Numerous situations can cause interrupts for PL/I, and some situations (such as ENDFILE) can be used to control normal program flow rather than to handle errors. ON-units allow you to obtain control after most interrupts.
If you do not write ON-units to obtain control after interrupts, you can:
The majority of PL/I conditions occur because of errors in program logic or the data supplied. Some, however, are not connected with errors. These are conditions such as ENDFILE, which are difficult to anticipate because they can occur at any time during program execution.
PL/I has both system messages and snap messages:
From offset xxx in a BEGIN block From offset xxx in procedure xxx From offset xxx in a condition_name ON-unit
These messages are repeated as often as necessary to trace back to the main procedure.
Condition_name condition was raised at offset xxx in procedure xxx.
The messages then continue as for SNAP SYSTEM messages.
If you want to translate offset numbers into statement numbers, use the following steps:
PL/I also provides condition-handling built-in functions and pseudovariables. These allow you to inspect various fields associated with the interrupt and, in certain cases, to correct the contents of fields causing the error.
These built-in functions include:
|
DATAFIELD ONCHAR ONCODE ONCONDCOND ONCONDID |
ONCOUNT ONFILE ONGSOURCE ONKEY ONLOC |
ONSOURCE ONWCHAR ONWSOURCE |
For detailed information on these condition-handling built-in functions and pseudovariables, consult the PL/I Language Reference.
There can only be one established ON-unit for an unqualified condition at any given point in a program, but there can be more than one established ON-unit for qualified conditions. For example, in handling the ENDFILE condition as qualified for different files, you can have an ON-unit established to uniquely handle the occurrence of ENDFILE for any one of the files.