Need authoritative source for why you shouldn't throw or catch java.lang.Exception -


I have met a coding standards meeting in just one hour and I need a quick reply to this.

The common knowledge among experienced Java programmers is that you do not throw java.lang.Exception or catch (with rare exceptions - no rhyme intentions). The reason for this is not that the statement

  hold (java.lang.Exception ex) {...}  

will also hold uncontrolled exceptions, and most cases It is not what it is intended in.

We have a number of legacy codes written by members of the current team where they capture a subclass of java.lang.Exception, log an error,

  1. They need to stop writing the code like this.
  2. This needs to be fixed to the existing code using anti-pattern

Number 2 means a reasonable amount of refactoring .

If I can, the argument in the meeting will be reduced by showing an article or blog entry by one of the Java community veterans who make this point (i.e. Joshua Block, James Gosling) Google-fu has not done anything yet.

Is anyone aware of an article or blog by a reputed java guru that you should not catch java or nap? exception?

Quick answers greatly appreciated.

Dean

Here are some: (JavaWorld)

(Second Edition) In Chapter 9 (Exception) by Joshua Bloch, there may be something on it, although I could not have got anything to catch exception quickly.

About this question (also points for Java Tip 134) - It also tells you to catch exception or even The rule does not have to be broken.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -