Make use of nested exceptions.
Higher layers 'wrap' exceptions caught from lower layers if they cant handle
them.

ummm... Ted explains it better than I do:
http://husted.com/struts/tips/015.html




-----Original Message-----
From: Nick Faiz [mailto:[EMAIL PROTECTED]
Sent: Monday, 8 December 2003 14:01
To: 'Struts Users Mailing List'
Subject: RE: [OT] Exception handling in a J2EE project.


Good question, I'm thinking about the same sort of thing myself.

I usually find it easier to give each server side component its own
exception, and to throw all exceptions up to the client side with an
appropriate message or error code. Obviously, exceptions fatal to the system
have to be sent to an administrator - usually through an appropriate log
comment or email.

If you try to put in too many layers between your exceptions and client view
it can be murder, down the line, when bug tracking and extending the
application.

Perhaps having a common exception class, from which all component exceptions
extend, is a nice idea, but I think it invites needless complexity.

Nick Faiz

-----Original Message-----
From: Prasenjit Narwade [mailto:[EMAIL PROTECTED]
Sent: Monday, 8 December 2003 4:31 PM
To: Struts Users Mailing List (E-mail)
Subject: [OT] Exception handling in a J2EE project.

Hi All,
      What is the best Hierarcy (framework) for handling exceptions in a
J2EE project.

      I am thinking of some roughly the following Hierarcy consisting
broadly of three categories :



      +  MyApplicationException extends Exception  ( For handling bussiness
exceptions.)
         - InsufficientBalanceException
         - InvalidPasswordException
         - etc.

      +  MySystemException extends RuntimeException (Non bussiness
exception, exception due to System problems)


      +  MyEJBException extends EJBException  (Not too sure if this is
required)



    My question is :

        1.  Is this approach correct ?

        2.  My application flow consists of
                ActionClass calls BussinessDelegate calls SessionBean calls
DAO      and
                ActionClass calls BussinessDelegate calls SessionBean calls
EntityBeans

            How should the exception for take place. Should it be something
like this:

                DAO throws some ApplicationException ...
                caught by SessionBean thrown as some EJBException ......
                caught by BussinessDelegate and do some handling



Regards,
Prasenjit.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to