pub trait WrapFailure: Sealed {
    type Return;

    fn wrap_failure_with<D, F>(self, message: F) -> Self::Return
    where
        D: Display + Send + Sync + 'static,
        F: FnOnce() -> D
; fn wrap_failure<D>(self, message: D) -> Self::Return
    where
        D: Display + Send + Sync + 'static
; fn with_context<D, F>(self, message: F) -> Self::Return
    where
        D: Display + Send + Sync + 'static,
        F: FnOnce() -> D
; fn context<D>(self, message: D) -> Self::Return
    where
        D: Display + Send + Sync + 'static
; }
Available on crate feature report only.
Expand description

This trait is meant to be the outcome analogue of both miette::WrapErr and eyre::WrapErr. Therefore, any type that implements WrapErr for either of these libraries will automatically work with WrapFailure.

This trait is sealed and cannot be implemented for types outside of this outcome.

Required Associated Types

The expected return type for an impl.

This will always be the same enumeration type, but with a Report in the error or failure position.

Required Methods

Wrap the failure value with a new adhoc error that is evaluated lazily only once an error does occur.

Wrap the failure value with a new adhoc error.

Compatibility re-export of wrap_failure_with for interop with anyhow and eyre.

Compatibility re-export of wrap_failure for interop with anyhow and eyre.

Implementations on Foreign Types

Implementation of WrapFailure for Result<T, E> for any implementations of WrapErr.

use outcome::report::{WrapFailure, Result, Report};

fn execute() -> Result<()> {
  ...
}

pub fn invoke() -> Result<Vec<u8>> {
  execute().wrap_failure("Failed to execute correctly")?;
  Ok(vec![])
}

Implementors