The TRY block allows you to test a section of code for exceptions that may occur during its execution. The CATCH block must specify the type of exception you wish to handle if one should occur during the execution of the TRY block. The FINALLY block allows you to execute a section of code following the TRY block, whether or not an exception occurred.
Context:
Procedure Division Statements
*> The example below shows that you can declare e at the point of use. *> It is in scope until the end-try. try display "exception test" catch e as type Exception display e::Message end-try
See also the Local Variables sample, available from Start > All Programs > Micro Focus Enterprise Developer > Samples > Visual COBOL Samples, under Language Reference for JVM COBOL.
In the TRY statement, the:
Your program can raise an exception using the RAISE statement and pass this exception back to the caller. This is commonly referred to as "throwing an exception".