Skip to main content

ViaRoot

Struct ViaRoot 

Source
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: M

Auto 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<M, Target, C> RootError<M, Target> for C
where Target: Error2, C: SourceToTarget<M, (), (), Target>,

Source§

fn build(self) -> Target

Creates a root error instance. Read more
Source§

fn build_with_location(self, location: Location) -> Target

Creates a root error with explicit location.
Source§

fn fail<T>(self) -> Result<T, Target>

Creates and returns a root error as Err(...). Read more
Source§

fn fail_with_location<T>(self, location: Location) -> Result<T, Target>

Creates and returns error with explicit location.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.