|
|||||
|
|||||
Related Syntax | Related Concepts | ||||
control structure |
rethrow |
Syntax
rethrow
You can use rethrow
to resume a caught throw. You can only use rethrow
within a catch block. The new instance of the throw is created regardless of any other throws pending, and is dealt with in the same manner as any other throw.
The new throw has the same name and all the parameters of the original throw, even if you did not list all the parameters in the rethrowing catch.
The following is an example of rethrow
used with #program-error
.
global integer my-first-counter initial {5} global integer my-second-counter initial {0} define integer function divide value integer numerator by value integer denominator as return numerator / denominator catch #program-error code error-code rethrow unless error-code = 1219 return 0 process do output "%d(my-first-counter) divided by %d(my-second-counter) is: " || "d" % divide my-first-counter by my-second-counter || "%n" done
The first catch of #program-error deals only with an attempt to divide by zero. Use rethrow
so that all other causes of a #program-error are rethrown and dealt with appropriately by other catch statements.
If a rethrow is not caught, the program will terminate.
Related Syntax |
Related Concepts |
Copyright © Stilo International plc, 1988-2010.