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