ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Best Practices for Exception Handling
Subject:   throw new Exception("...")
Date:   2003-11-20 01:59:31
From:   anonymous2
Response to: throw new Exception("...")

I agree. Also sometimes just subclassing the exception class makes it easier, in client code, to determine what exactly went wrong.


Catching an empty DuplicateUserName exception means I have a far better idea of what went wrong than by catching an Exception and then having to query the message to find out what its about. So if you are going to do some specific recovery stuff for specific exception types then I can't see a problem with subclassing Exception and adding no new methods.