Exception Handling Overview
Chapter 12. Handling Exceptions
This chapter explains how ILE RPG exception handling works, and how to use:
Exception handlers
ILE RPG-specific handlers
ILE condition handlers
Cancel handlers
ILE RPG supports the following types of exception handlers:
RPG-specific handlers, for example, the use of an error indicator, an 'E' opera-
tion code extender, or a *PSSR or INFSR error subroutine.
ILE condition handlers, user-written exception handlers that you register at run
time using the ILE condition handler bindable API CEEHDLR.
ILE cancel handler which can be used when a procedure ends abnormally.
Most programs benefit from some sort of planned exception handling because it
can minimize the number of unnecessary abnormal ends (namely, those associated
with function checks). ILE condition handlers also allow you to handle exceptions in
mixed-language applications in a consistent manner.
You can use the RPG exception handlers to handle most situations that might arise
in a RPG application. The minimum level of exception handling which RPG pro-
vides is the use of error indicators on certain operations. To learn how to use them,
read the following sections in this chapter:
“ILE RPG Exception Handling” on page 220
“Specifying Error Indicators or the 'E' Operation Code Extender” on page 227
Additionally, to learn how ILE exception handling works, read:
“Exception Handling Overview” (for general concepts)
“Using RPG-Specific Handlers” on page 226
The sections on error handling in
ILE Concepts
.
For information on exception handling and the RPG cycle, see
ILE RPG for AS/400
Reference
.
Note: In this book the term 'exception handling' is used to refer to both exception
handling and error handling. However, for consistency with other RPG
terms, the term 'error' is used in the context of 'error indicator' and 'error
subroutine'.
Exception Handling Overview
Exception handling is the process of:
Examining an exception message which has been issued as a result of a run-
time error
Optionally modifying the exception to show that it has been received (that is,
handled)
Copyright IBM Corp. 1994, 1999 217