For each text defined on the Texts tab page, the Class Builder generates a public constant of the same name. Constants may also be inherited from the superclasses of the exception class.
By default, the system raises an exception with the text that has the same name as the exception class. To raise the exception with another text, use the corresponding constant as the actual parameter for constructor parameter TEXTID.
Note: The type of the constants and parameter TEXTID in the constructor is determined by whether or not the exception class was created with the With message class flag. If the exception class still uses OTR texts, the constants are of type CHAR and contain a technical ID of the OTR text. If the exception class uses a message class, the constants are structures containing the name of the message class, the message number.
Exception Propagation
The handling of exceptions that occur within procedures does not have to lie within the same procedure. Instead, the procedure can propagate the exception to its caller. The caller can then handle the exception or propagate it to its own caller. The highest levels to which an exception can be propagated are processing blocks without local data areas, that is, event blocks or dialog modules. These processing blocks have to handle the propagated exceptions. Otherwise, a runtime error occurs. The same is true for exceptions raised within such processing blocks.
To propagate an exception from a procedure, you generally use the RAISING addition when you define the procedure interface. In methods of local classes and subroutines, specify the RAISING addition directly when you are defining the procedure. For example:
METHODS meth_name ... RAISING cx_... cx_... or FORM subr_name ... RAISING cx_... cx_....
The RAISING addition is followed by a list of the exception classes whose instances are to be propagated. In methods of global classes, enter exception classes whose instances are to be propagated into the exception table of the method in the Class Builder. You also need to set the Exception Class flag for each exception table. The process is similar for function modules. To set the indicator in Function Builder, choose the Exceptions tab.
Hint: A single method, subroutine, or function module can raise only one type of exception, that is, either class-based or conventional.
Propagating Exceptions Over Several Hierarchy – Levels
Propagation of class-based exception does not require that the calling method actually handles the exception. The caller may pass the exception to its own caller even without handling it.
In the example, the constructor propagates the CX_EXC exception raised by the GET_TECH_ATTR method. When the error occurs and the program raises the exception, the program flow jumps directly to the CATCH block in the main program.
Note: If the constructor implements the optional CLEANUP block, the system executes this block before the CATCH block of the main program.