3 ms·
If you're raising an exception deep in some internal code, provide as much detail as possible. If the error bubbles up to the user, then either the information
by magicalhippo 4y ago
If you're raising an exception deep in some internal code, provide as much detail as possible.
If the error bubbles up to the user, then either the information is over their head, in which case there's no difference to a non-detailed error message, or the user/support person can actually act on it.
The most infuriating error I see is "file not found"... WHICH FILE?!
Of course if the error is found in the higher level due to some consistency check in the business logic, then yeah try to guide the user. But for internal stuff, try to help the person who needs to fix it or find a workaround. It might be you.
- lupire 4y ago> The most infuriating error I see is "file not found"... WHICH FILE?! Filenames might contain user data, which must not be logged outside of a database with proper access control, schema annotations, and acccess auditing. We can only display an opaque object key, so authorized devs can look up the filename using secure tools.
- magicalhippo 4y agoFair enough. I work mostly with good old desktop applications though, so if there's user data, it's almost always the users data. For the majority of errors in most applications one can provide some helpful information. But yeah, one need to be a bit careful if one has PII in the mix.
- riskable 4y ago> If you're raising an exception deep in some internal code, provide as much detail as possible. > If the error bubbles up to the user, ...then you have an information disclosure vulnerability! There's a really good reason why we don't bubble up deep exceptions to end users: Attackers can use that info to gain information about your back end that they can use to find worse vulnerabilities. Put all the detail you want in your logs. Keep the end users out of it. They shouldn't be able to tell what line broke things.
- magicalhippo 4y agoYeah things are a bit different with web apps. There users usually can't do anything with the info even if they had details, so internal logs is clearly the place. But my point still stands: you want detailed info in those logs, not just a lone "file not found" without anything else.