[−][src]Struct extracterr::Bundled
An Error bundled with a Context can then later be extracted from a chain of dyn Errors.
Usage
This type has two primary methods of construction, From
and Bundle
. The first method of
construction, the From
trait, only works when the type you're bundling with the error
implements Default
. This is useful for types like Backtrace
s where the context you care
about is implicitly captured just by constructing the type, or for types that have a reasonable
default like HttpStatusCodes defaulting to 500.
use extracterr::Bundled; #[derive(Debug, thiserror::Error)] #[error("just an example error")] struct ExampleError; struct StatusCode(u32); impl Default for StatusCode { fn default() -> Self { Self(500) } } fn foo() -> Result<(), Bundled<ExampleError, StatusCode>> { Err(ExampleError)? }
The second method of construction, the Bundle
trait, lets you attach context to errors
manually. This is useful for types that don't implement Default
or types where you only
occasionally want to override the defaults.
use extracterr::{Bundled, Bundle}; #[derive(Debug, thiserror::Error)] #[error("just an example error")] struct ExampleError; struct StatusCode(u32); fn foo() -> Result<(), Bundled<ExampleError, StatusCode>> { Err(ExampleError).bundle(StatusCode(404))? }
Once context has been bundled with an error it can then be extracted by an error reporter with
the Extract
trait.
Implementations
impl<E, C: 'static> Bundled<E, C>
[src]
Trait Implementations
impl<E, C> Debug for Bundled<E, C> where
E: Error,
[src]
E: Error,
impl<E, C> Display for Bundled<E, C> where
E: Error,
[src]
E: Error,
impl<E, C> Error for Bundled<E, C> where
E: Error + 'static,
[src]
E: Error + 'static,
fn source<'a>(&'a self) -> Option<&'a (dyn Error + 'static)>
[src]
fn backtrace(&self) -> Option<&Backtrace>
[src]
fn description(&self) -> &str
1.0.0[src]
fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl<E, C> From<E> for Bundled<E, C> where
E: Error + Send + Sync + 'static,
C: Default,
[src]
E: Error + Send + Sync + 'static,
C: Default,
Auto Trait Implementations
impl<E, C> RefUnwindSafe for Bundled<E, C> where
C: RefUnwindSafe,
E: RefUnwindSafe,
C: RefUnwindSafe,
E: RefUnwindSafe,
impl<E, C> Send for Bundled<E, C> where
C: Send,
E: Send,
C: Send,
E: Send,
impl<E, C> Sync for Bundled<E, C> where
C: Sync,
E: Sync,
C: Sync,
E: Sync,
impl<E, C> Unpin for Bundled<E, C> where
C: Unpin,
E: Unpin,
C: Unpin,
E: Unpin,
impl<E, C> UnwindSafe for Bundled<E, C> where
C: UnwindSafe,
E: UnwindSafe,
C: UnwindSafe,
E: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,