[][src]Macro chainerror::strerr

macro_rules! strerr {
    ( $t:path, $msg:expr ) => { ... };
    ( $t:path, $msg:expr, ) => { ... };
    ( $t:path, $fmt:expr, $($arg:tt)+ ) => { ... };
    ($msg:expr) => { ... };
    ($msg:expr, ) => { ... };
    ($fmt:expr, $($arg:tt)+) => { ... };
}

Convenience macro for cherr!(T(format!(…))) where T(String)

Examples

derive_str_cherr!(Func2Error);

fn func2() -> ChainResult<(), Func2Error> {
    let filename = "foo.txt";
    Err(strerr!(Func2Error, "Error reading '{}'", filename))
}

derive_str_cherr!(Func1Error);

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