Article:
 |
|
Best Practices for Exception Handling
|
| Subject: |
|
Don't wrap exceptions! |
| Date: |
|
2003-11-27 05:39:31 |
| From: |
|
anonymous2
|
Response to: Don't wrap exceptions!
|
|
"This decision should NEVER be made by any library code because it shifts too much knowledge of a process into the client code; this in term severely limits reusability."
But it should *also* not be done by your business code - business code shouldn't know about SQL at all!
So, what you need is a persistence layer, specific to your application. If that layer decides that the Exception can't be handled reasonably, it's a good thing to wrap the original SqlException into a more generic PersistenceException or something.
|
Showing messages 1 through 3 of 3.
-
Don't wrap exceptions!
2003-12-01 08:14:43
anonymous2
[View]
-
Don't wrap exceptions!
2003-12-03 13:58:50
anonymous2
[View]
-
Don't wrap exceptions!
2008-07-31 00:20:09
kdgar
[View]
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.