Skip to main content

ErrorExt

Trait ErrorExt 

Source
pub trait ErrorExt:
    Error
    + Send
    + Sync
    + 'static {
    // Provided methods
    fn raise(self) -> Exn<Self>
       where Self: Sized { ... }
    fn and_raise<T: Error + Send + Sync + 'static>(self, context: T) -> Exn<T>
       where Self: Sized { ... }
    fn raise_erased(self) -> Exn
       where Self: Sized { ... }
    fn raise_all<T, I>(self, sources: I) -> Exn<Self>
       where Self: Sized,
             T: Error + Send + Sync + 'static,
             I: IntoIterator,
             I::Item: Into<Exn<T>> { ... }
}
Expand description

A trait bound of the supported error type of Exn.

Provided Methods§

Source

fn raise(self) -> Exn<Self>
where Self: Sized,

Raise this error as a new exception.

Source

fn and_raise<T: Error + Send + Sync + 'static>(self, context: T) -> Exn<T>
where Self: Sized,

Raise this error as a child of a new exception with the given context error.

This is a shorthand for self.raise().raise(context) — it wraps self in an Exn and immediately nests it under a new Exn<T> headed by context.

// Instead of:
io_err.raise().raise(message("could not read file"))

// Write:
io_err.and_raise(message("could not read file"))
Source

fn raise_erased(self) -> Exn
where Self: Sized,

Raise this error as a new exception, with type erasure.

Source

fn raise_all<T, I>(self, sources: I) -> Exn<Self>
where Self: Sized, T: Error + Send + Sync + 'static, I: IntoIterator, I::Item: Into<Exn<T>>,

Raise this error as a new exception, with sources as causes.

Implementors§

Source§

impl<T> ErrorExt for T
where T: Error + Send + Sync + 'static,