On this page
User exceptions, handlers, and exceptional contracts
Verada distinguishes user-declared exceptional outcomes from failed safety checks and infrastructure/resource failures. This distinction affects which handlers are legal, what a proof establishes, and what state a caller can observe after an operation propagates.
Declaring and raising user exceptions
A user exception is a declared identity, optionally renamed from another visible exception. Raising it transfers control to a matching supported handler or propagates it according to the operation's exceptional contract. A message can accompany the occurrence. Raising without a name inside a handler reraises the current occurrence.
An exception name is not an arbitrary integer status or an instance of any Python class. The frontend maps supported exception declarations to the common exception model. Vibe recognizes selected exception class declarations/raises; its Python built-in exception hierarchy and finally behavior are not generally available.
Propagation policy
A procedure can propagate the user exceptions listed by its Exceptional_Cases. Each listed consequence must hold at the corresponding exceptional exit. A user exception handled within the operation does not require declaring it as a propagated outcome, but any onward propagation still has to satisfy the enclosing policy.
procedure Read_Value (Value : out Integer)
with Exceptional_Cases => (Bad_Input => True);This is an interface fragment requiring visible Bad_Input and an implementation. The consequence True permits the exception without promising a further relationship; it does not promise that the procedure always raises, or that its other behavior is safe. Useful exceptional consequences should state the state relationships callers actually need.
Functions cannot specify propagated exceptional cases. A supported raise expression has the expected value type syntactically, but its path must satisfy the applicable reachability rules. An unhandled/unlisted raise must be proved unreachable (B5111). A failed exceptional consequence is B5113.
Handler selection and reraising
A handler names one or more exceptions or the supported others choice. Control reaches the applicable innermost handler, then continues after the handled block if the handler completes normally. A handler can itself raise or reraise, in which case the applicable outer handlers and propagation contracts govern the transfer.
Vada can bind an occurrence name and use Ada.Exceptions.Exception_Name, Exception_Message and Exception_Information (the name, then : and the message when there is one). The source presentation must make the required library visible. Ada.Exceptions.Reraise_Occurrence (X) of the occurrence its own handler names (when X : E1 | E2 =>) is raise;: the exception is one of the handler's choices, so the subprogram's Exceptional_Cases (or its callers' handlers) must cover them, as for any raise. Reraising an occurrence elsewhere, an outer handler's inside an inner one say, is not in Verada (B0501), since which exception it is the proof cannot know; raise the exception by name instead. Vibe occurrence-binding forms need their accepted imports and lowering; consult its exception chapter rather than assuming arbitrary except ... as ... introspection.
An others handler is not a wildcard for every failure in the compiler, solver, runtime, operating system, or foreign library. In particular it does not turn a failed Verada check into an application exception strategy; B8006 explains that boundary.
State on exceptional return
Normal postconditions apply to normal return. Exceptional consequences apply on the listed propagation. The body may have performed updates before raising; the entire procedure is not a transaction and no general rollback is implied.
Semantic by-reference types include tagged, class-wide, and limited types. Their changes can be visible to the caller before propagation. By-copy outputs do not receive normal copyback when the call raises. Consequently, exceptional contracts cannot name the new value of an ordinary by-copy out/in out formal as though it were the caller's updated value; entry snapshots are used in the permitted forms instead.
This is relevant to Vibe dataclasses: an ordinary untagged value passed through a procedure can have different exceptional update behavior from a mutable Python object reference. The compatibility chapter records this boundary. Do not infer semantic by-reference behavior from a pointer-shaped native ABI argument.
Cleanup
Propagation leaves nested scopes. Applicable reclaimed objects in those scopes are finalized on the way to the handler or operation boundary. Ownership analysis tracks moved parts and exception paths, so it does not silently duplicate or lose resource responsibility. A finalizer itself must satisfy its termination and resource requirements.
Objects whose lifetimes continue inside the handler must still meet the relevant initialized/ownership state before use. A handler cannot treat all values as restored to their entry state. REPL runtime-check failures can additionally poison written globals; that operational recovery policy is documented in the Toolchain Manual.
Failed checks and resources
Overflow, range, indexing, division, discriminant, null, length, predicate, tag, and contract checks are obligations of the checked/proved program. Strict compilation requires them to be established. Handlers for predefined check exceptions such as Constraint_Error are rejected as a method of handling unproved safety conditions (B1018).
Advisory/proof-disabled execution retains applicable runtime checks, but their failure reports through Verada's runtime policy rather than becoming a supported ordinary catchable user exception. This policy does not mean native programs are immune to stack/heap exhaustion, foreign faults, unavailable files, or process termination. Library I/O operations can expose declared user exceptions through their contracts, while general resource limits remain a separate assurance boundary.
For source spelling, use the three syntax references. For exact diagnostic and process output, use the Toolchain runtime/troubleshooting chapters and veradic explain CODE.