Rick Reumann on 03/05/06 23:40, wrote:
> Do I really want to have to wrap that with a try/catch or declare that
> it throws WhateverException? What does that really gain me?
I guess this is religion/style thing. I would never return SQLwhatever
exceptions to business/web layer, I would convert it.
Well the daos of course aren't in the web layer, but you bring up
another annoying thing about not using RTEs from a backend layer - you
end up now having to create other Exceptions to wrap things just so
your layer further up (like the web layer or even the service layer)
doesn't have to know about SQLExceptions. (ie more work and for what
gain?)
When you choose your exception handling / logging strategy, one of the
deciding factors is how much work you want to put into it.
Both struts and the servlet container provide mechanisms which reduce
the workload of whatever you decide upon, and some of those mechanisms
offered can be used on their own as the complete solution for RAD
projects, one-off apps etc.
At the other end of the scale, a well thought-out exception handling
strategy in a robust, extensible and modular architecture will entail
considerably more work than that.
For instance as Michael said you would:
- wrap layer-specific exceptions in the layer where they occur
- you would have a bespoke exception superclass
- packages of child exceptions with useful names
- useful functionality in the exception superclass to enhance logging or
monitoring mechanism
- your own exception handling algorithm in your action base class to
enhance flow of control
I think one thing you might want to do is to create your own exception
superclass and base it on the RuntimeException, i.e. make it unchecked.
Then you can wrap your layers' exceptions in it, throw it and not have
to catch it again.
Regards
Adam
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]