ContextExt

Trait ContextExt 

Source
pub trait ContextExt {
    // Required methods
    fn with_context<Frame: Into<BacktraceFrame>>(self, frame: Frame) -> Self;
    fn with_message(self, message: impl Into<Cow<'static, str>>) -> Self;
}
Expand description

The ContextExt trait allows extra information to be added to errors.

This is used to add tracking information to errors that bubble up from an inner field.

Required Methods§

Source

fn with_context<Frame: Into<BacktraceFrame>>(self, frame: Frame) -> Self

Adds a new context frame to the error, consuming the original error.

Source

fn with_message(self, message: impl Into<Cow<'static, str>>) -> Self

Adds a new frame of context to the error with the given message, consuming the original error.

This also adds the file name and line number of the caller to the error.

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.

Implementors§