Maintainability Improvement: avoid error suppression #710
HadesArchitect
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Dear contributors, we have to discuss the usage of exceptions in the project.
While working on logger replacement, I noticed a lot of empty catch blocks where nothing happens, but an error is just suppressed. For example, like this one:
I did a little search and found over 1k+ of such cases.
There are 1009 cases in my branch, and I have already refactored some of them, so the actual count is even higher.
Dear colleagues, I'd like to strongly discourage such practice. This approach makes maintenance of the application an absolute nightmare because whatever happens inside the try-catch block, any issue will be just suppressed and ignored: no warnings, no messages, nothing. Maybe one or two specific cases for an app is fine, but 1k+ definitely too much.
Proper Error Handling is not a simple thing, and there are multiple possible approaches, but I highly recommend avoiding Error Suppression at all costs and add at least log warnings, like here:
Such a warning will be logged to a console (and in a log file, if enabled) and will help us to understand what's happening, drastically decrease debug time in the future.
Thank you for your attention.
Beta Was this translation helpful? Give feedback.
All reactions