Struct pretty_error_debug::Wrapper
source · pub struct Wrapper<E: 'static + Error>(pub E);
Expand description
Wrap an Error
to display its error chain in debug messages (format!("{:?}")
).
Example
use some_external_mod::{SomeError, some_test};
fn main() -> Result<(), pretty_error_debug::Wrapper<SomeError>> {
some_test()?;
Ok(())
}
mod some_external_mod {
#[derive(Debug)]
pub struct SomeError;
impl std::error::Error for SomeError {}
impl std::fmt::Display for SomeError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("Something went wrong")
}
}
pub fn some_test() -> Result<(), SomeError> {
Err(SomeError)
}
}
Tuple Fields§
§0: E
Implementations§
Trait Implementations§
source§impl<E: 'static + Error> Error for Wrapper<E>
impl<E: 'static + Error> Error for Wrapper<E>
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
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()
source§impl<E: Ord + 'static + Error> Ord for Wrapper<E>
impl<E: Ord + 'static + Error> Ord for Wrapper<E>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<E: PartialEq + 'static + Error> PartialEq<Wrapper<E>> for Wrapper<E>
impl<E: PartialEq + 'static + Error> PartialEq<Wrapper<E>> for Wrapper<E>
source§impl<E: PartialOrd + 'static + Error> PartialOrd<Wrapper<E>> for Wrapper<E>
impl<E: PartialOrd + 'static + Error> PartialOrd<Wrapper<E>> for Wrapper<E>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<E: Copy + 'static + Error> Copy for Wrapper<E>
impl<E: Eq + 'static + Error> Eq for Wrapper<E>
impl<E: 'static + Error> StructuralEq for Wrapper<E>
impl<E: 'static + Error> StructuralPartialEq for Wrapper<E>
Auto Trait Implementations§
impl<E> RefUnwindSafe for Wrapper<E>where E: RefUnwindSafe,
impl<E> Send for Wrapper<E>where E: Send,
impl<E> Sync for Wrapper<E>where E: Sync,
impl<E> Unpin for Wrapper<E>where E: Unpin,
impl<E> UnwindSafe for Wrapper<E>where E: UnwindSafe,
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