Trait outcome::report::WrapFailure
source · [−]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
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
.
Implementations on Foreign Types
sourceimpl<T, E> WrapFailure for Result<T, E> where
Self: WrapErr<T, E>,
impl<T, E> WrapFailure for Result<T, E> where
Self: WrapErr<T, E>,
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![])
}