Handling Exceptions on the CALL Statement

An exception condition occurs on a CALL statement when the CALL operation itself fails. For example, the system may be out of storage or it may be unable to locate the called program. In this case, if you do not have an ON EXCEPTION or ON OVERFLOW clause on the CALL statement, your application may abnormally end. You use the ON EXCEPTION or ON OVERFLOW clause to detect the exception condition, prevent the abnormal end, and perform your own error-handling routine. For example:
     CALL "REPORTA"
        IN LIBRARY "MYLIB"
           ON EXCEPTION
               DISPLAY "Program REPORTA not available."
     END-CALL

If program REPORTA is unavailable or cannot be found in library MYLIB, control will continue with the ON EXCEPTION clause.

The ON EXCEPTION and ON OVERFLOW phrases handle only the exceptions that result from the failure of the CALL operation itself.

The ON EXCEPTION conditions that are signalled by the CALL operation are handled by a condition handler registered at priority 130. At this priority level, only conditions signalled to the specific call stack entry where the CALL statement exists will be handled. At this priority level, user written condition handlers may not get a chance to see signalled conditions.

If you do not have ON EXCEPTION and ON OVERFLOW phrases on the CALL statements in your application and the CALL statement fails, then the exception is handled by ILE condition handling. See ILE Condition Handling for an overview of ILE condition handling.