Skip to main content

ErrorExt

Trait ErrorExt 

Source
pub trait ErrorExt:
    Error
    + Send
    + Sync
    + 'static {
    // Provided methods
    fn raise(self) -> Error
       where Self: Sized { ... }
    fn raise_typed(self) -> Exn<Self>
       where Self: Sized { ... }
    fn and_raise<T: Error + Send + Sync + 'static>(self, context: T) -> Error
       where Self: Sized { ... }
    fn and_raise_typed<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

Raise native errors with caller locations and optional context.

Provided Methods§

Source

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

Raise this error at the caller’s location, returning a public Error. An existing Error is returned unchanged, preserving its representation and allocation.

Source

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

Raise this error as a typed exception, retaining Self even when it is already an Error.

Source

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

Raise this error as a cause of context, returning a public Error.

Tree-backed crate::Error values reuse their existing frame, retaining its original caller location.

Source

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

Like Self::and_raise(), retaining the context’s type in an exception.

Source

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

Raise this error as a new exception, with type erasure. Tree-backed crate::Error values reuse their existing frame and caller location.

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

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