This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
A method is not required to declare in its throws clause any subclasses of Error that might be thrown during the execution of the method but not caught, since these errors are abnormal conditions that should never occur.
There are all sorts of reasons. Application-specific exceptions can be used to encapsulate and/or encapsulate underlying framework exceptions, providing an easy way to apply declarative exception handling in a robust way, even if the underlying exceptions change. Application-specific exceptions can provide application-specific information in the exception (like a user ID, etc.)
Joined: Oct 13, 2005
It is obvious why we need application-specific Exceptions, but they are asking about Errors here.