IBM AS/400 Frozen Dessert Maker User Manual


 
Exception Handling Overview
2. If an 'E' operation code extender is present on the calculation specification and
the exception is one that is expected for that operation:
a. The return values for the built-in funtions %STATUS and %ERROR are set.
Note: %STATUS is set when any exception occurs even if the 'E'
extender is not specified.
b. The exception is handled
c. Control resumes with the next ILE RPG operation.
3. If no error indicator or 'E' extender is present
and
you have coded a *PSSR error subroutine and the exception is a program
exception
or
you have coded a INFSR error subroutine for the file and the exception is
an I/O exception,
then the exception will be handled and control will resume at the first statement
of the error subroutine.
4. If no error indicator, 'E' extender, or error subroutine is coded, then the RPG
default error handler is invoked.
If the exception is
not
a function check, then the exception will be
percolated.
If the exception is a function check, then an inquiry message will be dis-
played. If the 'G' or 'R' option is chosen, the function check will be handled
and control will resume at the appropriate point (*GETIN for 'G' or the same
calculation specification that received the exception for 'R') in the proce-
dure. Otherwise,the function check will be percolated and the procedure will
be abnormally terminated.
See “Unhandled Exceptions” on page 223 for a full description of the RPG default
handler.
Exception Handling within Subprocedures
Exception handling within a subprocedure differs from a main procedure in the fol-
lowing ways:
Because you cannot code an *INFSR subroutine, you should handle file errors
using error indicators or the 'E' operation code extender.
There is no default handler; in other words, users will never see an inquiry
message.
Exception handling within a subprocedure differs from a main procedure primarily
because there is no RPG cycle code generated for subprocedures. As a result
there is no default exception handler for subprocedures and so situations where the
default handler would be called for a main procedure correspond to abnormal end
of the subprocedure. This means that:
Factor 2 of an ENDSR operation for a *PSSR subroutine within a subprocedure
must be blank. A blank factor 2 in a main procedure would result in control
being passed to the default handler. In a subprocedure, if the ENDSR is
reached, then the subprocedure will end abnormally and RNX9001 will be sig-
nalled to the caller of the subprocedure.
Chapter 12. Handling Exceptions 221