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. - Residual
Error - A cheap, cloneable snapshot of an error’s rendered text.
- SError
- Wraps
Errorso it satisfies thestd::error::Errortrait where a'staticsource is required (e.g. insideanyhow). - Shared
Error - One error shared across many holders.
Enums§
- Error
- The workspace error. Each variant marks where a failure originated.
Traits§
- Context
Ext - Adds
.context(..)/.with_context(..)toResult<T>andOption<T>. - Host
Error - Any foreign error that can be carried as an
Error::HostLang. Blanket- implemented for everySend + Sync + 'staticstandard error. - Shared
Result Ext - Converts a
SharedResultinto a plainResultby extracting the shared error. SeeSharedErrorfor the degrade-after-first-take behavior. - Shared
Result ExtRef - Borrowing counterpart to
SharedResultExtfor&SharedResult<T>, yielding a borrowed value on success. - StdContext
Ext - Adds
.context(..)/.with_context(..)to aResultcarrying any foreignstd::error::Error, converting it to anError::Internalalong 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
Okin aSharedResult, so call sites need not nameSharedError.
Type Aliases§
- CError
- Backwards-compatibility alias for
Error. - CResult
- Backwards-compatibility alias for
Result. - Result
- A
Resultdefaulting to the workspaceError. - Shared
Result - A
Resultwhose error is aSharedError.