Ada Conformity Assessment Authority      Home Conformity Assessment   Test Suite ARGAda Standard
 
Ada Reference ManualLegal Information
Contents   Index   References   Search   Previous   Next 

11.3 Raise Statements and Raise Expressions

1
A raise_statement raises an exception. 

Syntax

2/2
raise_statement ::= raise;
      | raise exception_name [with string_expression];
2.1/4
raise_expression ::= raise exception_name [with string_simple_expression]
2.2/4
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:
2.3/4
object_declaration;
2.4/4
modular_type_definition;
2.5/4
floating_point_definition;
2.6/4
ordinary_fixed_point_definition;
2.7/4
decimal_fixed_point_definition;
2.8/4
default_expression;
2.9/4
ancestor_part.

Legality Rules

3/4
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

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

Dynamic Semantics

4/4
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
4.1/4
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

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

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe