error context
A message added to an error to say what the program was doing.
Error context wraps an error with a description of the failed operation ("reading config.toml"), so the report explains both what and why.
Loading interactive…
Examples
With anyhow,
fs::read_to_string(path).with_context(|| format!("reading {path}"))?printed with{e:#}givesreading notes.txt: No such file or directory (os error 2).
See also