-
Notifications
You must be signed in to change notification settings - Fork 18
When should Display
of Error
also print the cause?
#23
Comments
The subject has been brought up a few times before. Relevant SO question. Nevertheless, it is good for the subject to be brought up here, which might serve as a catalyst towards this consensus. |
ty @Enet4, that's a very good summary. To add some more to that, we're currently leaning towards the reporter based design, but it's too early to start pushing for it across the ecosystem because there are quite a few edge cases still where context for errors can be discarded because no reporter is ever used. Thing's like logging or printing errors directly, or panicking with For now, the recommendation is to always do one or the other. If you're going to print your sources, you should not return them via the |
anyhow prints the cause chain only with
{:#}
but tokio-postgres always prints the cause. This causes rust-postgres errors wrapped in anyhow errors to be printed twice if at all.https://github.com/sfackler/rust-postgres/blob/8f2ae8647bd2de68a77d85bfb005de3cfdd548a3/tokio-postgres/src/error/mod.rs#L396-L398
https://github.com/dtolnay/anyhow/blob/5e4177fc4c9e211feb90f1d81ea0ef183f171fa7/src/fmt.rs#L9-L13
The text was updated successfully, but these errors were encountered: