Design Guideline for Exception Handling ?

We have a four tier J2EE architecture with  a web application, a session

bean layer, a entity bean layer and an oracle database.
The system has interactive users. Errors can of course occur in any
layer. We want to give informative messages to the users about errors.

In the EJB specs there is application exceptions like FinderException,
CreateException and so on. These will mostly (or only) be thrown from
the entity beans and may be rethrown by the session bean layer. But are
they really useful in the web layer?

Has anybody in this community developed a successful strategy for
exception handling or can anybody give a hint about good patterns, books

or papers in this area?

Here is some of my thoughts about the topic:

1 You can not (do not want to) take care of all types of possible
exception everywhere in the architecture.
2 You do not want a layer to be dependent on exception types in all
layers below.
3 You do not want  zillions of exception types and explicit catch blocks

for all of them everywhere.
4 You do not want error messages hard coded where you throw an
exception.
5 You do not want to decorate all interfaces with all kinds of exception

types because most of the time you do not care about  the type of
exception.
6 You almost always want to roll back transactions when an exception
occured.
7 You do want the users to understand what has happend and what to do
about it.
8 You do not want to tell the user there was a
javax.ejb.XXXXXXException.
9 You do want the session bean layer to take care of the transaction
demarcation (implicitly).
10 You have to ensure your session beans throw EJBException if you want
to roll back transactions (according to the specs).
11 Every possible component shall not declare a special exception type.

I (we) do have a strategy and a design but I think there is a lack of
good useful patterns and I want to hear about other peoples oponions.

Regards
/Lars Hagrot

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to