#[repr(transparent)]pub struct Wrapper<E: Error + ?Sized + 'static>(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: Error + 'static> Error for Wrapper<E>
impl<E: Error + 'static> Error for Wrapper<E>
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()
Source§impl<E: Ord + Error + ?Sized + 'static> Ord for Wrapper<E>
impl<E: Ord + Error + ?Sized + 'static> 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: PartialOrd + Error + ?Sized + 'static> PartialOrd for Wrapper<E>
impl<E: PartialOrd + Error + ?Sized + 'static> PartialOrd for Wrapper<E>
impl<E: Copy + Error + ?Sized + 'static> Copy for Wrapper<E>
impl<E: Eq + Error + ?Sized + 'static> Eq for Wrapper<E>
impl<E: Error + ?Sized + 'static> StructuralPartialEq for Wrapper<E>
Auto Trait Implementations§
impl<E> Freeze for Wrapper<E>
impl<E> RefUnwindSafe for Wrapper<E>where
E: RefUnwindSafe + ?Sized,
impl<E> Send for Wrapper<E>
impl<E> Sync for Wrapper<E>
impl<E> Unpin for Wrapper<E>
impl<E> UnwindSafe for Wrapper<E>where
E: UnwindSafe + ?Sized,
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