Skip to main content

Module error

Module error 

Source
Expand description

The workspace error type and the helpers that build on it.

Error sorts every failure into one of four kinds — caller mistakes (client), internal faults (internal), errors from an embedding host language (host), and a Context wrapper that records a human-readable trail. The ContextExt / StdContextExt traits add .context(..) to Result and Option, and the client_* / internal_* / api_* macros build-and-bail in one line.

A few supporting types round it out: SError adapts Error to std::error::Error where a 'static source is required, SharedError shares one error across many waiters (degrading to a message after the first takes ownership), and ApiError is the boundary type for API responses.

Structs§

ApiError
The error type returned at the API boundary, wrapping an anyhow::Error.
ResidualError
A cheap, cloneable snapshot of an error’s rendered text.
SError
Wraps Error so it satisfies the std::error::Error trait where a 'static source is required (e.g. inside anyhow).
SharedError
One error shared across many holders.

Enums§

Error
The workspace error. Each variant marks where a failure originated.

Traits§

ContextExt
Adds .context(..) / .with_context(..) to Result<T> and Option<T>.
HostError
Any foreign error that can be carried as an Error::HostLang. Blanket- implemented for every Send + Sync + 'static standard error.
SharedResultExt
Converts a SharedResult into a plain Result by extracting the shared error. See SharedError for the degrade-after-first-take behavior.
SharedResultExtRef
Borrowing counterpart to SharedResultExt for &SharedResult<T>, yielding a borrowed value on success.
StdContextExt
Adds .context(..) / .with_context(..) to a Result carrying any foreign std::error::Error, converting it to an Error::Internal along the way.

Functions§

invariance_violation
Builds a generic “Invariance violation” error for an unreachable state that nonetheless needs a value rather than a panic.
shared_ok
Constructs an Ok in a SharedResult, so call sites need not name SharedError.

Type Aliases§

CError
Backwards-compatibility alias for Error.
CResult
Backwards-compatibility alias for Result.
Result
A Result defaulting to the workspace Error.
SharedResult
A Result whose error is a SharedError.