You can add a local variable to the method signature. Its type refers to the raised exception of the calling method. In addition, this local variable is added as an INTO clause to the already existing CATCH block. This enables you to handle the result of the exception in order, for example, to display it in a message.
Example
Before Execution | After Execution |
---|---|
To copy the source code example, click here Code Example Before Execution |
|
In the implementation of the drive method, the check_fuel method is called in a TRY CATCH block. Here, the cx_no_fuel exception that is raised in the public section is handled. The result of the exception now needs be handeld as a local variable after it is raised. |
In the signature of the drive method, the exc local variable is added with TYPE REF TO of the selected exception class. In addition, this local variable is added as an INTO clause at the end of the CATCH statement. |