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

后端 未结 9 1090
无人及你
无人及你 2020-12-19 09:27

I\'ve got a coding standards meeting in just over an hour and I need a quick answer to this one.

Common wisdom among experienced Java programmers is that you don\'t

9条回答
  •  独厮守ぢ
    2020-12-19 10:05

    Here's something: Java Tip 134: When catching exceptions, don't cast your net too wide (JavaWorld)

    Effective Java (Second Edition) by Joshua Bloch might have something on this in Chapter 9 (Exceptions), although I couldn't quickly find anything about not catching Exception.

    Here is a Q&A from JavaWorld about the question (also points to Java Tip 134) - it also explains why you sometimes have to break the rule of not catching Exception or even Throwable.

提交回复
热议问题