TRY
<guarded stmts>
EXCEPT
"|" <exception id> { "," <exception id> ... } "=>" <stmts>
(* Non-parameterized exceptions *)
"|" <exception id> "(" <parm id> ")" "=>" <stmts>
(* Parameterized exception handler *)
[ ELSE <stmts> ]
END
The TRY-EXCEPT statement guards statements between TRY and EXCEPT with the exception handlers between EXCEPT and END. An exception raised by a <guarded stmt> is handled by <stmts> in the corresponding handler, or by ELSE <stmts>, if present, and execution continues with the statement following END.
EXCEPTION Failure(Severity);
TYPE Severity = {Low, Medium, High};
...
TRY
...
EXCEPT
| IO.Error =>
IO.Put("An I/O error occurred.")
| Lex.Error =>
IO.Put("Unable to convert datatype.")
| Severity(x) =>
IF x = Severity.Low THEN IO.Put("Not bad") ELSE IO.Put("Bail out") END
END;