Struct pretty_error_debug::Wrapper
source · pub struct Wrapper<E: Error + 'static>(_);
Expand description
Instead of adding a new type, you can simply use this wrapper
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)
}
}
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)>
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()