Trait ErrorContext

Source
pub trait ErrorContext: Sealed {
    // Required methods
    fn context<C: Display>(self, context: C) -> Self;
    fn with_context<C: Display>(self, f: impl FnOnce(&Error) -> C) -> Self;
}
Expand description

Provides the context method for Error and Result<T, Error>.

Required Methods§

Source

fn context<C: Display>(self, context: C) -> Self

Wraps the error value with additional context.

Source

fn with_context<C: Display>(self, f: impl FnOnce(&Error) -> C) -> Self

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.

Implementations on Foreign Types§

Source§

impl<T> ErrorContext for Result<T, Error>

Source§

fn context<C: Display>(self, context: C) -> Self

Source§

fn with_context<C: Display>(self, f: impl FnOnce(&Error) -> C) -> Self

Implementors§