macro_rules! str_context {
($e:ident) => { ... };
}
Expand description
Convenience macro to create a “new type” T(String) and implement Display + Debug for T
§Examples
chainerror::str_context!(Func2Error);
fn func2() -> chainerror::Result<(), Func2Error> {
let filename = "foo.txt";
do_some_io().context(Func2Error(format!("Error reading '{}'", filename)))?;
Ok(())
}
chainerror::str_context!(Func1Error);
fn func1() -> Result<(), Box<dyn Error>> {
func2().context(Func1Error::new("func1 error"))?;
Ok(())
}