anyhow_ext
An extension of anyhow. A drop-in replacement of anyhow.
Features
- Attach file location info in error message
- Use
dotto make a small backtrace.
usage
Work with anyhow!
[]
= "1"
= "0.2"
Then use anyhow_ext::Context instead of anyhow::Context.
use ;
use Context;
drop-in replacement of anyhow
Since anyhow_ext re-exports all the thing in anyhow except for Context, you can use anyhow_ext as a drop-in replacement.
Cargo.toml
[]
= "0.2"
Then
use ;
How location info is displayed
println!("{}", err) looks like
foo err at `src/bin/anyhow_ext.rs@6:11`
and println!("{:?}", err) looks like
foo err at `src/bin/anyhow_ext.rs@6:11`
Caused by:
0: read_a_file err at `src/bin/anyhow_ext.rs@10:19`
1: an io err at `src/bin/anyhow_ext.rs@15:55`
2: No such file or directory (os error 2)
dot to make a small backtrace
use ;
This will make a small backtrace.
at `examples/dot.rs@14:34`
Caused by:
0: at `examples/dot.rs@20:11`
1: at `examples/dot.rs@9:11`
2: at `examples/dot.rs@4:52`
3: No such file or directory (os error 2)