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
top 1 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 3 years ago

It is already possible with https://docs.rs/problem/5.3.0/problem/ crate. You set up panic handler with format_panic_to_stderr() or format_panic_to_error_log() and wrap your errors in Problem type which will follow the Error trait source 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 why anyhow crate exists. So user friendly panic reporting is a CLI specific problem and not a general Rust issue.