handle
=>
. If
is an exception
literal, then if the exception
is
raised and not caught during the execution of
,
expression
is evaluated. If
is not a
literal exception, it is viewed as a variable name to which any exception
raised during the evaluation of
will be bound, for an
ensuing evaluation of
.
Using the variable-binding form of the try...handle block allows any PLAN exception to be caught. Therefore a simple error-reporting system may be set up. For example:
fun exnreport(h:host,e:exn):unit =
print("I raised ",e," on ",h)
fun main(...) =
try
...
handle e =>
OnRemote(exnreport(thisHost(),e),home,getRB(),defaultRoute)
. Evaluate the
handling expression of the tightest lexically-enclosing try...handle
construct. If there is no such enclosing construct, the exception will cause
the the termination of the program and the deletion of the packet.
Note that service calls and language constructs may raise exceptions which can be caught with try...handle blocks. As with uncaught exceptions raiseed by the PLAN program, these exceptions will cause the termination of the program and the deletion of the packet. The language-level exceptions are: