Function wrap

Source
pub fn wrap<D, E>(message: D, cause: E) -> impl Error
where D: Debug + Display + Send + Sync + 'static, E: Into<Box<dyn Error + Send + Sync>>,
Expand description

Wrap an error with some additional message.

Includes the error as the source of this wrapped error.

use std::error::Error;

let err = errors::wrap("exploded", "cat hair in generator");

assert_eq!(err.to_string(), "exploded");
assert_eq!(err.source().unwrap().to_string(), "cat hair in generator");
Examples found in repository?
examples/smoke.rs (line 10)
8fn one() -> Result<(), E> {
9    println!("> one");
10    two().map_err(|e| errors::wrap("two failed", e))?;
11    println!("< one");
12    Ok(())
13}