Go to the first, previous, next, last section, table of contents.
-
When an exception occurrence is raised, normal program execution is
abandoned and control is transferred to an applicable exception_handler,
if any. To handle an exception occurrence is to respond to the
exceptional event. To propagate an exception occurrence is to raise it
again in another context; that is, to fail to respond to the exceptional
event in the present context.
Dynamic Semantics
-
Within a given task, if the execution of construct a is defined by this
International Standard to consist (in part) of the execution of
construct b, then while b is executing, the execution of a is said to
dynamically enclose the execution of b. The innermost dynamically
enclosing execution of a given execution is the dynamically enclosing
execution that started most recently.
-
When an exception occurrence is raised by the execution of a given
construct, the rest of the execution of that construct is abandoned;
that is, any portions of the execution that have not yet taken place are
not performed. The construct is first completed, and then left, as
explained in See section 7.6.1 Completion and Finalization. Then:
-
If the construct is a task_body, the exception does not propagate
further;
-
If the construct is the sequence_of_statements of a
handled_sequence_of_statements that has a handler with a choice covering
the exception, the occurrence is handled by that handler;
-
Otherwise, the occurrence is propagated to the innermost dynamically
enclosing execution, which means that the occurrence is raised again in
that context.
-
When an occurrence is handled by a given handler, the
choice_parameter_specification, if any, is first elaborated, which
creates the choice parameter and initializes it to the occurrence. Then,
the sequence_of_statements of the handler is executed; this execution
replaces the abandoned portion of the execution of the
sequence_of_statements.
NOTES
-
(1) Note that exceptions raised in a declarative_part of a body are not
handled by the handlers of the handled_sequence_of_statements of that
body.
- 11.4.1: The Package Exceptions
- 11.4.2: Example of Exception Handling
Go to the first, previous, next, last section, table of contents.