Should snafu errors have the ability to display the report by default? #548
Replies: 2 comments 4 replies
-
|
I suppose that |
Beta Was this translation helpful? Give feedback.
-
|
The matter of providing a display implementation which prints the source is frequently brought up. I hope the comments in #390 explain the key concerns eloquently. SNAFU provides control over a SNAFU error type's If anything, there may be something SNAFU can do to more intuitively accommodate the scenario that Eyre users are already familiar with, though as far as I can tell we haven't reached any consensus on this. There is a report implementation, and it is understood that people want to use it for reporting, but they might forget to use it, since unlike eyre's |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Eyre allows users to configure the default display implementations for errors generated by Eyre, so that just doing
println!("{e}");will show the full error chain. Snafu has a similar Report type that works in a very similar way, but with the critical difference that it seems that one needs to explicitly convert snafu errors to the Report type in order for the error chain to get reported properly.This is not a big deal in classic CLI use cases where it's often sufficient to just put
#[snafu::report]on the main function. However, in server applications, which may have many asynchronous background loops, errors often just get printed immediately where they're observed, without there being a centralized place to report (and convert) these errors.This leads to it being very easy to accidentally just use
println!("{e}");instead ofprintln!("{}", Report::from_error(e));, causing the full error chain to not be displayed in our logs. Having similar functionality to eyre, where we could configure the default display impl for these errors would be useful in that we could enable the full error chain to always be reported, removing the need to always pay attention to whether errors are being correctly logged.Is a change like this something that would fit in the Snafu crate? If so, I'd be happy to try to contribute this functionality.
Beta Was this translation helpful? Give feedback.
All reactions