macro_rules! derive_str_context {
    ($e:ident) => { ... };
}
Expand description

Convenience macro to create a “new type” T(String) and implement Display + Debug for T

Examples

derive_str_context!(Func2Error);

fn func2() -> ChainResult<(), Func2Error> {
    let filename = "foo.txt";
    do_some_io().context(Func2Error(format!("Error reading '{}'", filename)))?;
    Ok(())
}

derive_str_context!(Func1Error);

fn func1() -> Result<(), Box<dyn Error>> {
    func2().context(Func1Error("func1 error".into()))?;
    Ok(())
}