Paul Sturrock wrote:
Michael Angstadt wrote:
Gian Franco wrote:Never ignore exceptions
Well, I wouldn't say never...
I think I would. What harm is there in reporting the exception if there is one? You don't need to throw it, but give the unfortunate developer who is maintaining your code come chance to workout what is happening.
There is no harm in terms of performance of the application. But I think that it does clutter your code and that it actually makes it more
difficult for developers to maintain. For example, not only must they read the method call, but they must also spend the time to notice that it's enclosed within a try/catch block. Then, they must look at all the exceptions that are caught and how the application handles them. Plus, it is annoying as a programmer to have to write this extra code in cases such as this because you
know that POST is a valid HTTP method and that the exception will, for all practical purposes, never be thrown.
But yes, I think that it's good to tell newer programmers that it is important to handle ALL exceptions because on the whole, this is true.