DEVELOPMENT EDITION · 769442725406
Library Reference
On this page

Ada.Exceptions

Limited snapshots of handled exception information, and the raising of a handler's own occurrence again.

Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.

Availability and ownership

Use inside a handler. Exception_Name gives the qualified name in upper case; Exception_Message gives the raise's message, whole; Exception_Information gives both, NAME or NAME: message. Reraise_Occurrence (X) of the occurrence its handler names (when X : E) is raise;, so the subprogram's Exceptional_Cases cover the handler's exceptions as for any raise; of any other occurrence, one kept and reraised elsewhere, it is not in Verada (B0501), as its exception is one the proof cannot know.

A client proof uses these contracts without proving the body again (see library assurance). Global => null excludes package-global effects, not changes made through an in out argument.

Import and instantiate

with Ada.Exceptions;
import Ada.Exceptions;

A Vibe module imports this unit's names with from Ada.Exceptions import Name; see library use across syntaxes. In Varc, keep each name's declared spelling and write & on arguments the call changes.

Contract and lifecycle reading

A Pre condition is the caller's obligation; a Post is what a normal return guarantees. What a postcondition does not state, a client cannot assume. Ghost functions are for contracts and ghost code. The family guide describes copying, lifetime, order and cost.

API 001

Exception_Occurrence (declaration) — Limited snapshot of a handled exception name/message, not a global logging subscription; handler context supplies the occurrence.

Declared interface:

type Exception_Occurrence is limited private;

API 002

Exception_Name (declaration) — The exception's full name, PACKAGE.NAME in upper case.

Declared interface:

function Exception_Name (X : Exception_Occurrence) return String
  with Global => null,
       Post => Exception_Name'Result'Length < Verada.Storage.Length_Bound;

API 003

Exception_Message (declaration) — The message of raise E with "...", whole, or "".

Declared interface:

function Exception_Message (X : Exception_Occurrence) return String
  with Global => null,
       Post => Exception_Message'Result'Length < Verada.Storage.Length_Bound;

API 004

Exception_Information (declaration) — The name and the message together: NAME, or NAME: message when there is a message.

Declared interface:

function Exception_Information (X : Exception_Occurrence) return String
  with Global => null,
       Post => Exception_Information'Result'Length <= 2 * Verada.Storage.Length_Bound;

API 005

Reraise_Occurrence (declaration) — The occurrence X raised again: only X of the handler that names it (when X : E), where it is raise;, so the subprogram's Exceptional_Cases cover the handler's exceptions as for any raise (another occurrence is left out: its exception is not known to the proof)

Declared interface:

procedure Reraise_Occurrence (X : Exception_Occurrence)
  with Import, Convention => Intrinsic, Global => null;

API 006

Current_Occurrence (declaration) — (Verada) the occurrence being handled: what when X : E names.

Declared interface:

function Current_Occurrence return Exception_Occurrence
  with Global => null;