Skip to content

Part 9 — Condition Handling and Diagnostics

9.1 Condition Handling Model

9.1.1 Overview

PL/I uses a condition-based exception handling model. When a condition is raised, the runtime searches for a matching ON-unit (handler). If no handler is found, the system action is taken (which varies by condition).

9.1.2 ON Statement

ON ENDFILE(INFILE) EOF_FLAG = '1'B;
ON CONVERSION ONCHAR() = '0';
ON ERROR BEGIN;
    PUT LIST('Error occurred: ', ONCODE());
END;

9.1.3 SIGNAL Statement

Explicitly raise a condition.

SIGNAL CONDITION(MY_CONDITION);

9.1.4 REVERT Statement

Remove a previously established ON-unit.

9.2 Supported Conditions

Condition Cause
ANYCONDITION Catch-all for any condition
AREA Memory allocation failure in an AREA
ATTENTION User interrupt
CONDITION(name) User-defined condition (raised by SIGNAL)
CONVERSION Invalid data conversion (e.g., 'ABC' to number)
ENDFILE(file) End of file reached on input
ENDPAGE(file) End of page reached on PRINT file
ERROR Generic error (catch-all)
FINISH Program termination
FIXEDOVERFLOW Fixed-point arithmetic overflow
INVALIDOP Invalid floating-point operation
KEY(file) Record key error (not found, duplicate)
NAME(file) Name not found in GET DATA
OVERFLOW Floating-point overflow
RECORD(file) Record size mismatch (truncation)
SIZE Significant digits lost in assignment
SQLEXCEPTION SQL error condition
STORAGE Insufficient storage for ALLOCATE
STRINGRANGE SUBSTR arguments out of range
STRINGSIZE String assignment truncation
SUBSCRIPTRANGE Array subscript out of bounds
TRANSMIT(file) Data transmission error
UNDEFINEDFILE(file) File could not be opened
UNDERFLOW Floating-point underflow
ZERODIVIDE Division by zero

9.3 Condition Built-in Functions

Function Description
ONCODE() Numeric code identifying the condition
ONCHAR() Character that caused CONVERSION
ONSOURCE() Source string that caused CONVERSION
PLIRETV() Return value from last CALL
PLIDUMP() Produce diagnostic dump

9.4 Runtime Diagnostics

9.4.1 Logging Configuration

  • Log4j-based logging framework
  • Configurable log levels (ERROR, WARN, INFO, DEBUG)
  • SQL statement logging via LoggableStatement
  • CICS command logging

9.4.2 Internationalization

Runtime error messages available in 6 languages: - English (default) - German - Spanish - French - Portuguese - Additional locales configurable

9.4.3 PLIDUMP — Diagnostic Dump

Produce a formatted dump of program state for debugging.