A TRY
-EXCEPT
statement has the form:
TRY Body EXCEPT id_1 (v_1) => Handler_1 | ... | id_n (v_n) => Handler_n ELSE Handler_0 ENDwhere
Body
and each Handler
are statements, each id
names
an exception, and each v_
is an identifier. The
``ELSE Handler_0
'' and each ``(v_
)
'' are optional.
It is a static error for an exception to be named more than once in the list
of id
's.
The statement executes Body
. If the outcome is normal, the except
clause is ignored. If Body
raises any listed exception id_
,
then Handler_
is executed. If Body
raises any other
exception and ``ELSE Handler_0
'' is present, then it is executed. In
either case, the outcome of the TRY
statement is the outcome of the
selected handler. If Body
raises an unlisted exception and
``ELSE Handler_0
'' is absent, then the outcome of the TRY
statement is the exception raised by Body
.
Each (v_
)
declares a variable whose type is the argument type
of the exception id_
and whose scope is Handler_
. When an
exception id_
paired with an argument x
is handled,
v_
is initialized to x
before Handler_
is executed.
It is a static error to include (v_
)
if exception
id_
does not take an argument.
If (v_
)
is absent, then id_
can be a list of
exceptions separated by commas, as shorthand for a list in which the rest of
the handler is repeated for each exception. That is:
id_1, ..., id_n => Handleris shorthand for:
id_1 => Handler | ... | id_n => Handler
It is a checked runtime error to raise an exception outside the dynamic scope
of a handler for that exception. A ``TRY EXCEPT ELSE
'' counts as a
handler for all exceptions.
m3-support@elego.de