adaniel (1) [Avatar] Offline
#1
The box "Carefully catching exceptions" on page 225:

Code example: The rethrow of the ControlThrowable is not necessary in this example since Exception will not catch ControlThrowable because ControlThrowable is a subtype of Throwable but not of Exception.

Generally it is better to catch Exception and not Throwable because Error is a subclass of Throwable and normally one does not want to catch such abnormal conditions.

From the javadoc of Error: An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions. The ThreadDeath error, though a "normal" condition, is also a subclass of Error because most applications should not try to catch it.

Probably the box should guide in this direction.
joshua.suereth (60) [Avatar] Offline
#2
Re: Carefully catching exceptions
Thanks for the suggestion! I do know that advice, but I wanted to call explicit attention to the issue of ControlThrowable because I know lots of developers who still feel justified catching Throwable in locations and assuming the worst. I will adapt the messaging a bit here.