try etry handle e =>
ehandle
Execute the expression etry. If e is an exception
literal, then if the exception e is
raised and not caught during the execution of etry,
expression ehandle is evaluated. If e is not a
literal exception, it is viewed as a variable name to which any exception
raised during the evaluation of etry will be bound, for an
ensuing evaluation of ehandle.
Using the variable-binding form of the try...handle
block allows any PLAN exception to be caught. Therefore a simple, in-packet
error-reporting system may be set up. For example :
svc print : 'a -> unit
fun exnreport(h:host list,e:exn) =
(print("I raised ");
print(e);
print(" on ");
print(h))
svc thisHost : void -> host list
svc getRB : void -> int
svc defaultRoute : host -> host * dev
fun main(home,...) =
try
...
handle e =>
OnRemote(|exnreport|(thisHost(),e),home,getRB(),defaultRoute)