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:   Don't wrap exceptions!
Date:   2003-12-01 08:14:43
From:   anonymous2
Response to: Don't wrap exceptions!

Sorry, but you're missing the point. Whether the business code knows about SQL or not is simply of no concern. Whether it is a SQLException or your "PersistenceException": the business code should not handle any exceptions it knows nothing about. And wrapping it only removed a single layer: if the business code itself is layered also do you wrap all exceptions of the lower layers???


Wrapping SQLException in something else does not solve anything: you still have to pass the exception around, and have some layer handle it.


What I'm saying is that IF you have a SQL error that you do not fix in the originating layer you may as well pass it upwards and have topmost layer decide what to do with it: report some critical failure and log the ACTUAL problem instead of logging the wrapper.


1 to 1 of 1
  1. Don't wrap exceptions!
    2003-12-03 13:58:50  anonymous2 [View]

1 to 1 of 1