pub struct ViaRoot<M>(pub M)
where
M: Display + Debug + Send + Sync + 'static;Expand description
Wrapper for creating root errors with BoxedError2.
Use with .context() to create errors from non-Error types
like strings or custom messages.
§Example
use error2::prelude::*;
fn validate(value: i32) -> Result<(), BoxedError2> {
if value < 0 {
// Create a root error from a string message
ViaRoot("validation failed: negative value").fail()?;
}
Ok(())
}
Tuple Fields§
§0: MAuto Trait Implementations§
impl<M> Freeze for ViaRoot<M>where
M: Freeze,
impl<M> RefUnwindSafe for ViaRoot<M>where
M: RefUnwindSafe,
impl<M> Send for ViaRoot<M>
impl<M> Sync for ViaRoot<M>
impl<M> Unpin for ViaRoot<M>where
M: Unpin,
impl<M> UnwindSafe for ViaRoot<M>where
M: 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
Source§impl<M, Target, C> RootError<M, Target> for C
impl<M, Target, C> RootError<M, Target> for C
Source§fn build_with_location(self, location: Location) -> Target
fn build_with_location(self, location: Location) -> Target
Creates a root error with explicit location.
Source§fn fail_with_location<T>(self, location: Location) -> Result<T, Target>
fn fail_with_location<T>(self, location: Location) -> Result<T, Target>
Creates and returns error with explicit location.