[][src]Macro chainerror::derive_str_cherr

macro_rules! derive_str_cherr {
    ($e:ident) => { ... };
}

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

Examples

derive_str_cherr!(Func2Error);

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

derive_str_cherr!(Func1Error);

fn func1() -> Result<(), Box<Error>> {
    func2().map_err(mstrerr!(Func1Error, "func1 error"))?;
    Ok(())
}