Trait pnmixerlib::errors::ResultExt
[−]
pub trait ResultExt<T, E> { fn chain_err<F, EK>(self, callback: F) -> Result<T, Error>
where
F: FnOnce() -> EK,
EK: Into<ErrorKind>; fn from_err(self) -> Result<T, Error>
where
Error: From<E>; }
Additional methods for Result
, for easy interaction with this crate.
Required Methods
fn chain_err<F, EK>(self, callback: F) -> Result<T, Error> where
F: FnOnce() -> EK,
EK: Into<ErrorKind>,
F: FnOnce() -> EK,
EK: Into<ErrorKind>,
If the Result
is an Err
then chain_err
evaluates the closure,
which returns some type that can be converted to ErrorKind
, boxes
the original error to store as the cause, then returns a new error
containing the original error.
fn from_err(self) -> Result<T, Error> where
Error: From<E>,
Error: From<E>,
Converts a convertible error via From::from
to
the result error. Useful to turn e.g. std::io::Error
into our own Error type.