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:   Custom exceptions always have information for client code!
Date:   2003-12-23 03:00:26
From:   sebastien.couturiaux
Response to: A few things

I also disagree on the fact that you shouldn't throw custom exceptions.


My opinion is that custom exceptions always have at least one precious piece of information for client code : their type !!!!


Suppose I create an XYZService that can throw XYZException, simply extending RuntimeException without any additional attribute or method. The ture added value of my custom exception is that I will be able in the client code to filter exception handling precisely for exceptions coming from this XYZService.