Skip to main content

ErrorContext

Trait ErrorContext 

Source
pub trait ErrorContext<T> {
    // Required methods
    fn context(self, message: impl Into<String>) -> Result<T>;
    fn with_context<F, M>(self, f: F) -> Result<T>
       where F: FnOnce() -> M,
             M: Into<String>;
}
Expand description

Extension trait for adding context to errors.

Required Methods§

Source

fn context(self, message: impl Into<String>) -> Result<T>

Add context to an error.

§Errors

Returns Err if the original value was Err, wrapping it in an Internal error with the given message.

Source

fn with_context<F, M>(self, f: F) -> Result<T>
where F: FnOnce() -> M, M: Into<String>,

Add context lazily (only computed on error).

§Errors

Returns Err if the original value was Err, wrapping it in an Internal error with the context message.

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, E: Into<FraiseQLError>> ErrorContext<T> for Result<T, E>

Source§

fn context(self, message: impl Into<String>) -> Result<T>

Source§

fn with_context<F, M>(self, f: F) -> Result<T>
where F: FnOnce() -> M, M: Into<String>,

Implementors§