1 2 3 4 5 6 7 8 9 10 11 12 13
use fn_error_context::context; #[context("context")] fn do_stuff(arg: String) -> anyhow::Result<()> { anyhow::bail!("error {}", arg) } fn main() { assert_eq!( format!("{:#}", do_stuff("hello".to_owned()).unwrap_err()), "context: error hello" ); }