Spec-Zone.ru › Ada 2012
Ada 2012 Reference Manual

11.3 Raise Statements and Raise Expressions

A raise_statement raises an exception.

Syntax

raise_statement ::= raise;
| raise exception_name [with string_expression];
raise_expression ::= raise exception_name [with string_simple_expression]
If a raise_expression appears within the expression of one of the following contexts, the raise_expression shall appear within a pair of parentheses within the expression:
object_declaration;
modular_type_definition;
floating_point_definition;
ordinary_fixed_point_definition;
decimal_fixed_point_definition;
default_expression;
ancestor_part.

Legality Rules

The exception_name, if any, of a raise_statement or raise_expression shall denote an exception. A raise_statement with no exception_name (that is, a re-raise statement) shall be within a handler, but not within a body enclosed by that handler.

Name Resolution Rules

The string_expression or string_simple_expression, if any, of a raise_statement or raise_expression is expected to be of type String.
The expected type for a raise_expression shall be any single type.

Dynamic Semantics

To raise an exception is to raise a new occurrence of that exception, as explained in 11.4. For the execution of a raise_statement with an exception_name, the named exception is raised. Similarly, for the evaluation of a raise_expression, the named exception is raised. In both of these cases, if a string_expression or string_simple_expression is present, the expression is evaluated and its value is associated with the exception occurrence. For the execution of a re-raise statement, the exception occurrence that caused transfer of control to the innermost enclosing handler is raised again.
NOTES
1 If the evaluation of a string_expression or string_simple_expression raises an exception, that exception is propagated instead of the one denoted by the exception_name of the raise_statement or raise_expression.

Examples

Examples of raise statements:
raise Ada.IO_Exceptions.Name_Error; -- see A.13
raise Queue_Error with "Buffer Full"; -- see 9.11
raise; -- re-raise the current exception


Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API