Trait ErrorContext
pub trait ErrorContext: SealedErrorContext {
type Context;
// Required methods
fn context<M>(self, context: M) -> Self::Context
where M: Display + Send + Sync + 'static;
fn with_context<C, F>(self, context: F) -> Self::Context
where C: Display + 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.
§Examples
use rama_error::ErrorContext;
let result = "hello".parse::<i32>().context("parse integer");
assert_eq!("parse integer\r\n ↪ invalid digit found in string", result.unwrap_err().to_string());
Required Associated Types§
type Context
type Context
The resulting contexct type after adding context to the contained error.
Required Methods§
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.