ErrWith

Trait ErrWith 

Source
pub trait ErrWith<ReportErr, ReportOk, E> {
    // Required methods
    fn err_with<F>(self, f: F) -> Result<ReportOk, (ReportErr, E)>
       where F: FnOnce() -> ReportErr;
    fn err_with_report(
        self,
        report: &ReportErr,
    ) -> Result<ReportOk, (ReportErr, E)>
       where ReportErr: Clone;
}
Expand description

Trait to add extra context or information to an error.

Required Methods§

Source

fn err_with<F>(self, f: F) -> Result<ReportOk, (ReportErr, E)>
where F: FnOnce() -> ReportErr,

Wraps an error with additional context generated by a closure.

§Errors

Returns Err if the original Result is Err.

Source

fn err_with_report(self, report: &ReportErr) -> Result<ReportOk, (ReportErr, E)>
where ReportErr: Clone,

Wraps an error with additional context provided by a reference.

§Errors

Returns Err if the original Result is Err.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<ReportErr, ReportOk, E, IntoError> ErrWith<ReportErr, ReportOk, E> for Result<ReportOk, IntoError>
where IntoError: Into<E>,

Source§

fn err_with<F>(self, f: F) -> Result<ReportOk, (ReportErr, E)>
where F: FnOnce() -> ReportErr,

Wraps an error with additional context generated by a closure.

Source§

fn err_with_report(self, report: &ReportErr) -> Result<ReportOk, (ReportErr, E)>
where ReportErr: Clone, Self: Sized,

Wraps an error with additional context provided by a reference.

Implementors§