pub trait ErrorContext<T, E>: Sealed {
// Required methods
fn error_context<C>(self, context: C) -> Result<T, GenericError>
where C: Display + Send + Sync + 'static;
fn with_error_context<C, F>(self, f: F) -> Result<T, GenericError>
where C: Display + Send + Sync + 'static,
F: FnOnce() -> C;
}
Expand description
Helper methods for providing context on errors.
Slightly different than anyhow::Context
as the methods on this trait are named to avoid conflicting with
similarly-named methods provide by snafu
.
Required Methods§
Sourcefn error_context<C>(self, context: C) -> Result<T, GenericError>
fn error_context<C>(self, context: C) -> Result<T, GenericError>
Wrap the error value with additional context.
Sourcefn with_error_context<C, F>(self, f: F) -> Result<T, GenericError>
fn with_error_context<C, F>(self, f: F) -> Result<T, GenericError>
Wrap the error value with additional context that is evaluated lazily only once an error does occur.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.