Run-time Errors

If an error occurs at run time, a message appears on the terminal.

You can use Open PL/I's ON statement to develop handlers for the conditions that can occur in your program. The ON ERROR statement can be used for arbitrary errors. The ONLOC built-in function can be used in an ON-unit to report the name of an entry in which a condition was raised, and the ONCODE built-in function can be used to report the status value of a run-time error.

Note:

If an error is not caught by an ON-unit, Open PL/I displays the source file and line number where the error occurred. For these features to work, however, you must have compiled the source file with the default option -unixdebug.

This feature is currently available only in the Sun Solaris 2 and IBM AIX versions of Open PL/I.

When a fatal error condition occurs at run time, a message is displayed naming the condition that has been raised; the program address where this occurred; and the source file, entry, and line number at which the condition was raised, as well as the lines in each procedure above it in the call stack. For example:

*** Condition ERROR raised 
***Unhandled condition ZERODIVIDE at PC=00010233 
CALCDIV line 26 in /dirl/dir2/calcs.pl1 
SUBR3 line 444 in /dirl/dir2/subprog.pl1 
MYPROG line 871 in /dirl/dir2/mainprog.pl1

In this example,

CALCDIV Is the entry in which the "ZERODIVIDE" condition was raised.
SUBR3 Is the entry that called "CALCDIV" (at line 444).
MYPROG     Is the program that called SUBR3.

If you have compiled your program using the -nounixdebug option, only the program address where the condition was raised will be displayed:

*** Condition ERROR raised 
*** Unhandled condition ZERODIVIDE at PC=00010233