this post was submitted on 02 Jul 2021
7 points (100.0% liked)
Rust Programming
8438 readers
42 users here now
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
It is already possible with https://docs.rs/problem/5.3.0/problem/ crate. You set up panic handler with
format_panic_to_stderr()
orformat_panic_to_error_log()
and wrap your errors inProblem
type which will follow theError
traitsource
chain and produce nice message. It can even include stack traces.I am not sure if this should be in
stdlib
since normally panics are bugs and bug reports should be formatted in the way that developers can understand the best. But in CLI programs it is often easier for the developer to just abort with panic on normal errors (not bugs) and then you want nice report for the user by default. This is also the reason whyanyhow
crate exists. So user friendly panic reporting is a CLI specific problem and not a general Rust issue.