Is there any resource (web or book) describing exception handling / error handling design patterns?
There is a lot of literature on how to write clean code, and there are a lot of books covering design patterns. I have, however, never seen any design pattern covering the issue of where and how best to handle errors and how best to propagate an error appearing in a low-level function up the levels of abstraction.
Generally a try/catch/finally block is written for handling exception which could go terribly wrong very soon. If you are logging exception in catch block you have got it wrong already. If you are trying to recover from the exception and continuing the code flow then you are right.
There are three types of errors in programming: (a) Syntax Errors, (b) Runtime Errors, and (c) Logical Errors.
These patterns and best practices are often bound to a specific platform/language, so they are the first place to look for them.
As an example check the following links for java:
Going through such materials would give you a general idea to follow in exception handling mechanisms.
Also check other SO questions:
Best approach is never to swallow any exceptions within your application code. Hookup a handler to unhandled exceptions in your applications when bootstrapping where you can show an error message and do some logging.
Some decent books i've read recommended this approach.
http://thibautvs.com/blog/?p=2238 is a good one where it's mentioned.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With