Skip to main content

ErrorContext

Trait ErrorContext 

Source
pub trait ErrorContext: SealedErrorContext {
    type Context;
    type OpaqueContext;

Show 16 methods // Required methods fn into_box_error(self) -> Self::Context; fn into_opaque_error(self) -> Self::OpaqueContext; fn context<M>(self, value: M) -> Self::Context where M: Debug + Display + Send + Sync + 'static; fn context_hex<M>(self, value: M) -> Self::Context where M: Debug + Send + Sync + 'static; fn context_debug<M>(self, value: M) -> Self::Context where M: Debug + Send + Sync + 'static; fn context_field<M>(self, key: &'static str, value: M) -> Self::Context where M: Debug + Display + Send + Sync + 'static; fn context_str_field<M>(self, key: &'static str, value: M) -> Self::Context where M: Into<String>; fn context_hex_field<M>(self, key: &'static str, value: M) -> Self::Context where M: Debug + Send + Sync + 'static; fn context_debug_field<M>( self, key: &'static str, value: M, ) -> Self::Context where M: Debug + Send + Sync + 'static; fn with_context<C, F>(self, cb: F) -> Self::Context where C: Debug + Display + Send + Sync + 'static, F: FnOnce() -> C; fn with_context_hex<C, F>(self, cb: F) -> Self::Context where C: Debug + Send + Sync + 'static, F: FnOnce() -> C; fn with_context_debug<C, F>(self, cb: F) -> Self::Context where C: Debug + Send + Sync + 'static, F: FnOnce() -> C; fn with_context_field<C, F>(self, key: &'static str, cb: F) -> Self::Context where C: Debug + Display + Send + Sync + 'static, F: FnOnce() -> C; fn with_context_str_field<C, F>( self, key: &'static str, cb: F, ) -> Self::Context where C: Into<String>, F: FnOnce() -> C; fn with_context_hex_field<C, F>( self, key: &'static str, cb: F, ) -> Self::Context where C: Debug + Send + Sync + 'static, F: FnOnce() -> C; fn with_context_debug_field<C, F>( self, key: &'static str, cb: F, ) -> Self::Context where C: Debug + Send + Sync + 'static, F: FnOnce() -> C;
}
Expand description

Extends the Result and Option types with methods for adding context to errors.

See the module level documentation for more information.

Required Associated Types§

Source

type Context

The resulting context type after adding context to the contained error.

Source

type OpaqueContext

The resulting context type after turning the error into an opaque error

Required Methods§

Source

fn into_box_error(self) -> Self::Context

Return a err variant for Self::Context as BoxError.

Source

fn into_opaque_error(self) -> Self::OpaqueContext

Return a err variant for Self::OpaqueContext as OpaqueError.

Source

fn context<M>(self, value: M) -> Self::Context
where M: Debug + Display + Send + Sync + 'static,

Add context to the contained error.

Source

fn context_hex<M>(self, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static,

Add context to the contained error, using fmt::LowerHex as fmt::Debug and fmt::Display.

Source

fn context_debug<M>(self, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static,

Add context to the contained error, using fmt::Debug as fmt::Display.

Source

fn context_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Debug + Display + Send + Sync + 'static,

Add keyed context to the contained error.

Source

fn context_str_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Into<String>,

Same as Self::context_field but using a string-like value, this is useful in case you need to pass a string slice which is borrowed and thus cannot be passed as part of ’static error.

Source

fn context_hex_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static,

Add keyed context to the contained error using fmt::LowerHex as fmt::Debug and fmt::Display.

Source

fn context_debug_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static,

Add keyed context to the contained error using fmt::Debug as fmt::Display.

Source

fn with_context<C, F>(self, cb: F) -> Self::Context
where C: Debug + Display + Send + Sync + 'static, F: FnOnce() -> C,

Lazily add a context to the contained error, if it exists.

Source

fn with_context_hex<C, F>(self, cb: F) -> Self::Context
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Lazily add a context to the contained error, if it exists. using fmt::LowerHex as fmt::Debug and fmt::Display.

Source

fn with_context_debug<C, F>(self, cb: F) -> Self::Context
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Lazily add a context to the contained error, if it exists. using fmt::Debug as fmt::Display.

Source

fn with_context_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
where C: Debug + Display + Send + Sync + 'static, F: FnOnce() -> C,

Lazily add keyed context to the contained error, if it exists.

Source

fn with_context_str_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
where C: Into<String>, F: FnOnce() -> C,

Same as Self::with_context_field but using a string-like value, this is useful in case you need to pass a string slice which is borrowed and thus cannot be passed as part of ’static error.

Source

fn with_context_hex_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Lazily add keyed context to the contained error, if it exists using fmt::LowerHex as fmt::Debug and fmt::Display.

Source

fn with_context_debug_field<C, F>( self, key: &'static str, cb: F, ) -> Self::Context
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Lazily add keyed context to the contained error, if it exists using fmt::Debug as fmt::Display.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, E: Into<BoxError>> ErrorContext for Result<T, E>

Source§

type Context = Result<T, Box<dyn Error + Sync + Send>>

Source§

type OpaqueContext = Result<T, OpaqueError>

Source§

fn into_box_error(self) -> Self::Context

Source§

fn into_opaque_error(self) -> Self::OpaqueContext

Source§

fn context<M>(self, value: M) -> Self::Context
where M: Debug + Display + Send + Sync + 'static,

Source§

fn context_hex<M>(self, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static,

Source§

fn context_debug<M>(self, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static,

Source§

fn context_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Debug + Display + Send + Sync + 'static,

Source§

fn context_str_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Into<String>,

Source§

fn context_hex_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static,

Source§

fn context_debug_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static,

Source§

fn with_context<C, F>(self, cb: F) -> Self::Context
where C: Debug + Display + Send + Sync + 'static, F: FnOnce() -> C,

Source§

fn with_context_hex<C, F>(self, cb: F) -> Self::Context
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Source§

fn with_context_debug<C, F>(self, cb: F) -> Self::Context
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Source§

fn with_context_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
where C: Debug + Display + Send + Sync + 'static, F: FnOnce() -> C,

Source§

fn with_context_str_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
where C: Into<String>, F: FnOnce() -> C,

Source§

fn with_context_hex_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Source§

fn with_context_debug_field<C, F>( self, key: &'static str, cb: F, ) -> Self::Context
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Source§

impl<T> ErrorContext for Option<T>

Source§

type Context = Result<T, Box<dyn Error + Sync + Send>>

Source§

type OpaqueContext = Result<T, OpaqueError>

Source§

fn into_box_error(self) -> Self::Context

Source§

fn into_opaque_error(self) -> Self::OpaqueContext

Source§

fn context<M>(self, value: M) -> Self::Context
where M: Debug + Display + Send + Sync + 'static,

Source§

fn context_hex<M>(self, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static,

Source§

fn context_debug<M>(self, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static,

Source§

fn context_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Debug + Display + Send + Sync + 'static,

Source§

fn context_str_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Into<String>,

Source§

fn context_hex_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static,

Source§

fn context_debug_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static,

Source§

fn with_context<C, F>(self, cb: F) -> Self::Context
where C: Debug + Display + Send + Sync + 'static, F: FnOnce() -> C,

Source§

fn with_context_hex<C, F>(self, cb: F) -> Self::Context
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Source§

fn with_context_debug<C, F>(self, cb: F) -> Self::Context
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Source§

fn with_context_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
where C: Debug + Display + Send + Sync + 'static, F: FnOnce() -> C,

Source§

fn with_context_str_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
where C: Into<String>, F: FnOnce() -> C,

Source§

fn with_context_hex_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Source§

fn with_context_debug_field<C, F>( self, key: &'static str, cb: F, ) -> Self::Context
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Implementors§