pub struct Error { /* private fields */ }Expand description
An error type that extends anyhow::Error with named fields.
Implementations§
Source§impl Error
impl Error
Sourcepub fn with_field<V>(self, key: &'static str, value: V) -> Errorwhere
V: Display,
pub fn with_field<V>(self, key: &'static str, value: V) -> Errorwhere
V: Display,
Add a named field to this error.
Sourcepub fn with_field_debug<V>(self, key: &'static str, value: V) -> Errorwhere
V: Debug,
pub fn with_field_debug<V>(self, key: &'static str, value: V) -> Errorwhere
V: Debug,
Add a named field with debug formatting to this error.
Sourcepub fn get_field(&self, key: &str) -> Option<&str>
pub fn get_field(&self, key: &str) -> Option<&str>
Get a specific field value by key, this is an O(n) operation.
Sourcepub fn context<C>(self, context: C) -> Error
pub fn context<C>(self, context: C) -> Error
Add context to this error, see anyhow::Context for more details.
Sourcepub fn with_context<C, F>(self, f: F) -> Error
pub fn with_context<C, F>(self, f: F) -> Error
Add context to this error with a closure, see anyhow::Context for more details.
Sourcepub fn root_cause(&self) -> &dyn Error
pub fn root_cause(&self) -> &dyn Error
Get the root cause of this error.
Sourcepub fn downcast_ref<E>(&self) -> Option<&E>
pub fn downcast_ref<E>(&self) -> Option<&E>
Downcast the error to a reference to a concrete type.
Sourcepub fn downcast_mut<E>(&mut self) -> Option<&mut E>
pub fn downcast_mut<E>(&mut self) -> Option<&mut E>
Downcast the error to a mutable reference to a concrete type.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> ErrorContext for Twhere
T: Debug,
impl<T> ErrorContext for Twhere
T: Debug,
Source§fn with_context(&self, operation: &str) -> String
fn with_context(&self, operation: &str) -> String
Generate a standardized error message with context.