Skip to content

stdlib.error

Error Trait Hierarchy

Generated from v0.60.1. 4 source files, 48 documented symbols.

backtrace.xi

type BtError

An error carrying an optional symbolized backtrace (frames) and the raw frame addresses (raw) from which the symbols were derived.

NOTE: named BtError (not Error) because Error is treated as a compiler-reserved type name in this build and breaks cross-module codegen.

Field Type
message Str
frames Vec[Str]
raw Vec[Int]

Derives: Clone

fn error_backtrace_new(message: Str) -> BtError

Create an error carrying message and no backtrace. Bootstrap helper (the frozen stubs provide no constructor). Complexity: O(1).

fn error_backtrace(e: BtError) -> Vec[Str]

The symbolized backtrace of an error, if captured (empty otherwise). Complexity: O(frames).

  • Postcondition: result.len() == error_backtrace_depth(e)
fn error_capture_backtrace() -> Vec[Str]

Capture the current stack as symbol strings. The runtime has no stack walking intrinsic yet, so this returns an empty vector (documented). Complexity: O(1).

fn error_backtrace_enabled() -> Bool

Whether backtrace capture is currently enabled. Complexity: O(1).

fn error_set_backtrace_enabled(on: Bool)

Enable or disable backtrace capture. When disabled, error_with_backtrace attaches no frames. Complexity: O(1).

fn error_backtrace_frames(e: BtError) -> Vec[Int]

The raw frame addresses of an error backtrace (empty when none captured). Complexity: O(frames).

  • Postcondition: result.len() >= 0
fn error_backtrace_symbolize(frames: &Vec[Int]) -> Vec[Str]

Symbolize raw frame addresses as 0x hex strings. Invalid or negative addresses render as "0x0". Complexity: O(frames).

  • Postcondition: result.len() == frames.len()
fn error_with_backtrace(e: BtError) -> BtError

Capture the current stack and attach it to an error. In this build the captured stack is empty (see error_capture_backtrace), so the returned error carries the same message with empty frames. Complexity: O(1).

fn error_has_backtrace(e: BtError) -> Bool

Whether an error carries a backtrace (has at least one frame). Complexity: O(1).

fn error_backtrace_depth(e: BtError) -> Int

The number of frames in an error backtrace. Complexity: O(1).

  • Postcondition: result >= 0



chain.xi

type ChainError

An ChainError node: messages[0] is the newest message (head), the last element is the root. The chain is the full ordered list of messages.

Field Type
messages Vec[Str]

Derives: Clone

fn error_chain_new(message: Str) -> ChainError

Create a chain with a single message. Complexity: O(1).

fn error_chain_push(e: ChainError, message: Str) -> ChainError

Add message onto the chain and return the new head. The previous chain becomes the new chain's root portion. Complexity: O(len(chain)).

  • Postcondition: error_chain_len(result) == error_chain_len(e) + 1
fn error_chain_pop(e: ChainError) -> Option[ChainError]

Remove and return the head, exposing the previous cause. Returns None when the chain has only one message (nothing left beneath the head). Complexity: O(len(chain)).

  • Postcondition: result is Some(_) => error_chain_len(e) >= 2
  • Postcondition: result is None => error_chain_len(e) <= 1
fn error_chain_len(e: ChainError) -> Int

The number of messages in the chain. Complexity: O(1).

  • Postcondition: result >= 0
fn error_chain_messages(e: ChainError) -> Vec[Str]

All messages from head to root, newest first. Complexity: O(len(chain)).

  • Postcondition: result.len() == error_chain_len(e)
fn error_chain_root(e: ChainError) -> Str

The oldest (root) message. Complexity: O(1).

fn error_chain_top(e: ChainError) -> Str

The newest (head) message. Complexity: O(1).

fn error_chain_iter(e: ChainError) -> Vec[ChainError]

All nodes from head to root. Node i is the chain whose head is message i, i.e. an ChainError holding messages i..len. Complexity: O(len(chain)^2) total for the sliced copies.

  • Postcondition: result.len() == error_chain_len(e)
fn error_chain_has(e: ChainError, message: Str) -> Bool

Whether any node in the chain carries message. Complexity: O(len(chain) * len(message)) for the content comparison.




context.xi

type ContextError

An error node with per-layer messages and free-form context, plus the key/value pairs attached to the head layer. When an Error is wrapped, the previous head's pairs become part of the (now non-head) cause.

Field Type
messages Vec[Str]
free Vec[Str]
keys Vec[Str]
values Vec[Str]

Derives: Clone

fn error_context_new(message: Str) -> ContextError

Create a single-layer Error with message and no context. Bootstrap helper (the frozen stubs provide no constructor). Complexity: O(1).

fn error_with_context(e: ContextError, context: Str) -> ContextError

Attach a free-form context string to an Error (head layer). Returns a new Error; the original is unchanged. Complexity: O(1).

fn error_context(e: ContextError) -> Option[Str]

The free-form context string of the head layer, if any. Complexity: O(1).

fn error_wrap(e: ContextError, message: Str) -> ContextError

Wrap e with an outer message. The wrapped Error becomes the cause. Complexity: O(len(chain)).

fn error_unwrap(e: ContextError) -> Str

The underlying message of the Error (head layer). Complexity: O(1).

fn error_attach_context(e: ContextError, key: Str, value: Str) -> ContextError

Attach a named key/value pair to the head layer. Returns a new Error. Complexity: O(head pairs).

fn error_context_get(e: ContextError, key: Str) -> Option[Str]

The value stored under key on the head layer, if any. Complexity: O(head pairs).

fn error_context_keys(e: ContextError) -> Vec[Str]

All context keys of the head layer, in attach order. Complexity: O(head pairs).

  • Postcondition: result.len() == error_context_all(e).len()
fn error_context_all(e: ContextError) -> Vec[(Str, Str)]

All context pairs of the head layer; each tuple is (key, value). Complexity: O(head pairs).

fn error_pretty_print(e: ContextError) -> Str

Format an error for display: message (context: <free>; k=v, ...) when context exists, or just message otherwise. Complexity: O(len(message) + len(context)).

fn error_pretty_print_chain(e: ContextError) -> Str

Format an Error and its full chain, head first, as "outer <- inner (context: ...) <- root". Complexity: O(len(chain) * message lengths).




error.xi

type ErrorChain

Chain of error messages collected from an error value.

Field Type
errors Vec[Str]

Derives: Clone

fn chain(self: Self) -> ErrorChain

Collect this error's message chain (outermost first).

  • Postcondition: result.errors.len() >= 1

fn display(self: Self) -> Str

Render the chain as a single multi-line string.

fn wrap_error[T, E](result: Result[T, E], context: Str) -> Result[T, Str]

Wrap the Err payload of result with a context message, preserving Ok values unchanged. The Err message becomes just context -- the richer context + ": " + e.description() form needs the E: Error bound, which the checker's builtin-interface matching does not support yet (C001: bound resolves against the OK type; interface-as-value gap). The Error interface with Option[Error] returns also defaults to i64 (unknown-type warning). Re-enrich once the checker closes those gaps.

fn context[T, E](result: Result[T, E], msg: Str) -> Result[T, Str]

Wrap a Result error with an additional context message.

type Backtrace

Captured call-site frames (best-effort, platform dependent).

Field Type
frames Vec[Str]

Derives: Clone

fn capture_backtrace() -> Backtrace

Capture the current backtrace.

fn display(self: Self) -> Str

Render the frames as a single multi-line string.

fn error_message(err: Str) -> Str

Returns the error message unchanged. Identity helper for code clarity. Complexity: O(1). Pure, no side effects.

  • Postcondition: result == err

fn make_error(msg: Str) -> Str

Creates an error message string. Alias for readability at call-sites. Complexity: O(1). Pure, no side effects.

  • Postcondition: result == msg

fn error_context(msg: Str, ctx: Str) -> Str

Formats msg with additional context: "msg (context: ctx)". Complexity: O(len(msg)+len(ctx)). Pure, no side effects.

  • Postcondition: result.len() == msg.len() + ctx.len() + 12

fn error_join(a: Str, b: Str) -> Str

Joins two error messages with ": " separator. If a is empty, returns b. If b is empty, returns a. Complexity: O(len(a)+len(b)). Pure, no side effects.

  • Postcondition: a.len() == 0 => result == b
  • Postcondition: b.len() == 0 => result == a
  • Postcondition: a.len() > 0 && b.len() > 0 => result.len() == a.len() + b.len() + 2

fn option_ok_or[T](o: Option[T], msg: Str) -> Result[T, Str]

Converts an Option[T] into a Result[T, Str]. Some(v) ? Ok(v), None ? Err(msg). Complexity: O(1). Pure, no side effects.

  • Postcondition: o is Some(_) => result is Ok(_)
  • Postcondition: o is None => result is Err(_)

type HardwareFault

D2.1 (Unsafe Confinement Phase 5, requirement g): recoverable hardware-fault error returned when an unsafe block traps (SIGSEGV/SIGILL/SIGFPE/...).

Field Type
signal Str
pc UInt64
retried Bool

type ContractViolation

Description of a violated contract (used by the runtime).

Field Type
contract Str