Beruflich Dokumente
Kultur Dokumente
Objectives
Overview
What is wrong with Classical exception handling
Treatable Exceptions in Release 6.10 and later
Benefits of class based exceptions
Class-Based Exceptions
Exception Classes
Triggering Class-Based Exceptions
Handling Class-Based Exceptions
Creating a global exception class
July-2007
July-2007
July-2007
Example Code
All exceptions must be handled immediately after the function call, which is
cumbersome.
There is no way to group similar exceptions, except through the use of others.
Exceptions returned from classical exceptions are merely return codes and affect
no flow control processing
July-2007
July-2007
July-2007
Exception Classes
Exception classes are subclasses of the Global class:
CX_STATIC_CHECK
Exceptions defined through One of the sub classes of CX_STATIC_CHECK have to be either
handled within a procedure or passed on explicitly with the addition RAISING.
However this is verified by the syntax check.
CX_DYNAMIC_CHECK
Exceptions defined through One of the sub classes of CX_DYNAMIC_CHECK have to be either
handled within a procedure or passed on explicitly with the addition RAISING.
This is not verified by syntax check and the check is postponed until an exception occurs.
CX_NO_CHECK
Exceptions defined through One of the sub classes of CX_NO_CHECK can be either handled
within a procedure or passed on implicitly.
We should not use Class CX_NO_CHECK or its subclasses explicitly in the RAISING addition,
as they are already contained implicitly.
July-2007
NOTE: The old and new ways of handling exceptions cant be mixed in
routines!
July-2007
10
July-2007
CLEANUP
Clean up block is executed whenever an exception occurs within the TRY block and is not
handled by a CATCH within the same TRY block, BUT is handled by an surrounding TRY
block
ENDTRY
11
July-2007
Demonstration
Handling Class based exceptions:
Example Code
12
July-2007
Demonstration
Propagation of Class-Based exceptions in procedures to the caller.
Class-based exceptions in procedures can be propagated to the caller in the
definition of the interface using the RAISING addition, if the exception is not to be
handled in the procedure.
Example Code
13
July-2007
Demonstration
Detailed information about an exception ca be obtained from objects that are
created from exception classes when error is trapped.
Example Code
14
July-2007