Raise Statements
Author: JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor

Ada Reference Manual — Legal Information

# 11.3 Raise Statements

1
A raise_statement raises an exception.

#### Syntax

2/2
raise_statement ::= raise;
| raise exception_ name [with string_ expression];

#### Legality Rules

3
The name, if any, in a raise_statement 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/2
The expression, if any, in a raise_statement, is expected to be of type String.

#### Dynamic Semantics

4/2
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. If a string_ 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.

#### 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

Ada 2005 and 2012 Editions sponsored in part by Ada-Europe