pub enum Error {
Context {
msg: String,
source: Box<SError>,
},
HostLang(Box<dyn HostError>),
Client {
msg: String,
bt: Backtrace,
},
Internal(Error),
}Expand description
The workspace error. Each variant marks where a failure originated.
Variants§
Context
A message wrapping an inner error, forming a context trail.
HostLang(Box<dyn HostError>)
An error surfaced from an embedding host language (e.g. Python).
Client
A caller mistake — bad input or a failed precondition. Carries a
backtrace and renders as Invalid Request: ...
Internal(Error)
An internal fault, holding an anyhow::Error for flexible context.
Implementations§
Source§impl Error
impl Error
Sourcepub fn host(e: impl HostError) -> Self
pub fn host(e: impl HostError) -> Self
Wraps a host-language error as Error::HostLang.
Sourcepub fn client(msg: impl Into<String>) -> Self
pub fn client(msg: impl Into<String>) -> Self
Builds a Error::Client from a message, capturing a backtrace.
Sourcepub fn internal(e: impl Into<Error>) -> Self
pub fn internal(e: impl Into<Error>) -> Self
Wraps any Into<anyhow::Error> as Error::Internal.
Sourcepub fn internal_msg(msg: impl Into<String>) -> Self
pub fn internal_msg(msg: impl Into<String>) -> Self
Builds an Error::Internal straight from a message.
Sourcepub fn backtrace(&self) -> Option<&Backtrace>
pub fn backtrace(&self) -> Option<&Backtrace>
Returns the backtrace, if this error (or the error it wraps) captured one. Host-language errors have none.
Sourcepub fn without_contexts(&self) -> &Error
pub fn without_contexts(&self) -> &Error
Peels off any Context layers to reach the underlying
error.
Sourcepub fn source(&self) -> Option<&(dyn Error + 'static)>
pub fn source(&self) -> Option<&(dyn Error + 'static)>
Returns this error’s source, if any, for chain traversal.
Sourcepub fn context<C: Into<String>>(self, context: C) -> Self
pub fn context<C: Into<String>>(self, context: C) -> Self
Wraps this error in a Context layer carrying context.
Sourcepub fn with_context<C: Into<String>, F: FnOnce() -> C>(self, f: F) -> Self
pub fn with_context<C: Into<String>, F: FnOnce() -> C>(self, f: F) -> Self
Like context, but builds the message lazily — f runs
only on the error path.
Sourcepub fn std_error(self) -> SError
pub fn std_error(self) -> SError
Wraps this error in an SError so it satisfies a 'static
std::error::Error bound.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()