IBM AS/400 Frozen Dessert Maker User Manual


 
Exception Handling Overview
tion. If it remains unhandled, then the entry is removed and the function check is
percolated. The process repeats until the exception is handled.
In ILE, an exception message is associated with the
procedure
which is active on
the call stack. When the exception is percolated, it is
not
converted to a function
check. Each call stack entry is given a chance to handle the original exception until
the control boundary is reached. Only then is the exception converted to a function
check, at which point the exception processing starts all over again beginning with
the procedure which received the exception. This time each call stack entry is given
a chance to handle the function check. If the control boundary is reached and the
exception is still unhandled then a generic failure exception message CEE9901 is
sent to the caller of the procedure at the control boundary. In addition, any call
stack entry which did not to handle the message is removed.
ILE RPG Exception Handling
ILE RPG provides three types of exception handling mechanisms:
An error indicator or an 'E' operation code extender handler
An error subroutine handler
A default exception handler
RPG categorizes exceptions into two classes, program and file; this determines
which type of error subroutine is called. Some examples of program exceptions are
division by zero, out-of-bounds array index, or SQRT of a negative number. Some
examples of file exceptions are undefined record type or a device error.
There are four ways for you to indicate that RPG should handle an exception. You
can:
1. Specify an error indicator in positions 73 - 74 of the calculation specifications of
the appropriate operation code.
2. Specify the operation code extender 'E' for the appropriate operation code.
3. Code a file error subroutine, which is defined by the INFSR keyword on a file
description specification, for file exceptions. The file error subroutine can only
be coded in the main source section. You cannot code an INFSR for a file that
is used in a subprocedure.
4. Code a program error subroutine, which is named *PSSR, for program
exceptions. Note that a *PSSR is local to the procedure in which it is coded.
This means that a *PSSR in a main procedure will handle only those program
errors associated with the main procedure. Similarly, a *PSSR in a subproce-
dure will only handle the errors in that subprocedure.
Exception Handling within a Main Procedure
When an exception occurs within a main procedure ILE RPG does the following:
1. If an error indicator is present on the calculation specification and the exception
is one that is expected for that operation:
a. The indicator is set on
b. The exception is handled
c. Control resumes with the next ILE RPG operation.
220 ILE RPG for AS/400 Programmer's Guide