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.
I have the following exceptions and would like opinions on them.
In my Database I have a super exception DatabaseException this is the parent class for all DatabaseExceptions and I have coded the provided interface exceptions from DB.java as subclasses of this exception. DatabaseException extends Exception.
In my server I have a Business Exception which once again is subclass of Exception but a super class to all business layer exceptions like..
SCJP 6.0, SCJD (400/400), SCBCD for JEE 5, SCWCD 1.4 I do videos for development at
I am probably the only developer ever to have had an orange sized brain tumor in my brain while learning development!!
Personally, it looks to me you have too many exceptions. Think from the client side, how many exceptions do the client code need to catch?
I'm doing URLyBird, and I use a service layer between database and client. I have 2 exceptions (DatabaseException and RemoteException from RMI or some server exception if you like) to worry about at the end. My DB interface has 2 exceptions: RecordNotFoundException and DuplicateKeyException. In my service layer I catch these then throw my DatabaseException.
Also I don't recommend making the exceptions from DB interface a subclass of your own DatabaseException or Java's exception subclass such as IOException. Just make it subclass Exception will be fine. This is because the behavior may be different.