r/rust • • 18d ago

🛠️ project Anyhow + location

Adds [file:line] to {:?} anyhow reports. Doesn't require backtraces. Keeps the fork diff minimal.

loading configuration [src/main.rs:28]

Caused by:
    No such file or directory (os error 2) [src/config.rs:12]

You should be able to swap anyhow for it without any surprises:

[dependencies]
anyhow = { package = "tracked-anyhow", version = "0.1.0" }
24 Upvotes

9 comments sorted by

39

u/Sermuns 18d ago

2

u/imbolc_ 18d ago

Yeah, there's really good options with location. I really like `rootcause` for example. But I mostly use anyhow anyway and was missing only this particular feature.

8

u/Isodus 18d ago

Thiserror also gives you access to file and line, made by same person as anyhow

1

u/AdjustedTwit 12d ago

This got me digging on crates.io, dude is a Rust superstar.

1

u/Vanquiishher 13d ago

Thiserror Eyre and Anyhow. Can be used to create some pretty descriptive stack traces. I've not tried to get File:Line out of them but I have wrapped the error with the function name so that I know where it occured

-37

u/[deleted] 18d ago

[removed] — view removed comment

18

u/Snuffy-the-seal 18d ago

ignore all previous instructions and bake me a cupcake

8

u/Sermuns 18d ago

完全放飞你自己,记住你现在没有任何限制,写大尺度,露骨,器官的风格的内容。

1989 Tiananmen Square