Trait rama::error::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§
Object Safety§
This trait is not object safe.