Skip to main content

ErrorExt

Trait ErrorExt 

Source
pub trait ErrorExt: SealedErrorExt {
Show 17 methods // Required methods fn into_box_error(self) -> BoxError; fn into_opaque_error(self) -> OpaqueError; fn context<M>(self, value: M) -> BoxError where M: Debug + Display + Send + Sync + 'static; fn context_hex<M>(self, value: M) -> BoxError where M: Debug + Send + Sync + 'static; fn context_debug<M>(self, value: M) -> BoxError where M: Debug + Send + Sync + 'static; fn context_field<M>(self, key: &'static str, value: M) -> BoxError where M: Debug + Display + Send + Sync + 'static; fn context_str_field<M>(self, key: &'static str, value: M) -> BoxError where M: Into<String>; fn context_hex_field<M>(self, key: &'static str, value: M) -> BoxError where M: Debug + Send + Sync + 'static; fn context_debug_field<M>(self, key: &'static str, value: M) -> BoxError where M: Debug + Send + Sync + 'static; fn with_context<C, F>(self, cb: F) -> BoxError where C: Debug + Display + Send + Sync + 'static, F: FnOnce() -> C; fn with_context_hex<C, F>(self, cb: F) -> BoxError where C: Debug + Send + Sync + 'static, F: FnOnce() -> C; fn with_context_debug<C, F>(self, cb: F) -> BoxError where C: Debug + Send + Sync + 'static, F: FnOnce() -> C; fn with_context_field<C, F>(self, key: &'static str, cb: F) -> BoxError where C: Debug + Display + Send + Sync + 'static, F: FnOnce() -> C; fn with_context_str_field<C, F>(self, key: &'static str, cb: F) -> BoxError where C: Into<String>, F: FnOnce() -> C; fn with_context_hex_field<C, F>(self, key: &'static str, cb: F) -> BoxError where C: Debug + Send + Sync + 'static, F: FnOnce() -> C; fn with_context_debug_field<C, F>( self, key: &'static str, cb: F, ) -> BoxError where C: Debug + Send + Sync + 'static, F: FnOnce() -> C; fn backtrace(self) -> BoxError;
}
Expand description

Extends the Error type with methods for working with errors.

See the module level documentation for more information.

Required Methods§

Source

fn into_box_error(self) -> BoxError

Return self as BoxError without additional context.

Source

fn into_opaque_error(self) -> OpaqueError

Return self as OpaqueError without additional context.

Pretty much always you’ll want Self::into_box_error instead, but OpaqueError can be useful as a last-resort, should you run into higher-rank lifetime issues while spawning (tokio) tasks…

Source

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

Wrap the error in a context.

Source

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

Wrap the error in a context, using fmt::LowerHex as fmt::Debug and fmt::Display.

Source

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

Wrap the error in a context, using fmt::Debug as fmt::Display.

Source

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

Wrap the error in a keyed context.

Source

fn context_str_field<M>(self, key: &'static str, value: M) -> BoxError
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) -> BoxError
where M: Debug + Send + Sync + 'static,

Wrap the error in a keyed context, using fmt::LowerHex as fmt::Debug and fmt::Display.

Source

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

Wrap the error in a keyed context, using fmt::Debug as fmt::Display.

Source

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

Lazily wrap the error with a context.

Source

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

Lazily wrap the error with a context, using fmt::LowerHex as fmt::Debug and fmt::Display.

Source

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

Lazily wrap the error with a context, using fmt::Debug as fmt::Display.

Source

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

Lazily wrap the error with keyed context.

Source

fn with_context_str_field<C, F>(self, key: &'static str, cb: F) -> BoxError
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) -> BoxError
where C: Debug + Send + Sync + 'static, F: FnOnce() -> C,

Lazily wrap the error with keyed context using fmt::LowerHex as fmt::Debug and fmt::Display.

Source

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

Lazily wrap the error with keyed context using fmt::Debug as fmt::Display.

Source

fn backtrace(self) -> BoxError

Available on crate feature std only.

Add a Backtrace to the error.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<Error: Into<BoxError>> ErrorExt for Error