pub trait ErrorContext {
// Required method
fn with_context<C, F>(self, context: F) -> Self
where C: Context,
F: FnOnce() -> C;
}Expand description
Propose additional error context for the error to consider collecting.
The information provided to ErrorContext should be thought of as debugging
information only. You should never depend on any of this information
logically.
Whether or not this context information is collected depends on how you
define your Error type.
Required Methods§
Sourcefn with_context<C, F>(self, context: F) -> Self
fn with_context<C, F>(self, context: F) -> Self
Provide human-readable context about why an error occurred.
Context is collected if the error supports it with the proper
envelopes. If collected, it will be printed in stack order (first
piece of context added prints first, followed by the next, etc).
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: ErrorContext> ErrorContext for Result<T, E>
impl<T, E: ErrorContext> ErrorContext for Result<T, E>
fn with_context<C, F>(self, context: F) -> Self
Source§impl<T: ErrorContext> ErrorContext for Option<T>
impl<T: ErrorContext> ErrorContext for Option<T>
fn with_context<C, F>(self, context: F) -> Self
Implementors§
impl<K: ErrorKind> ErrorContext for Described<K>
Available on crate feature
alloc only.impl<K: ErrorKind> ErrorContext for Diagnostic<K>
Available on crate feature
alloc only.