Hi,
What we do in our project is, we have a top level exception class, say,
RootException(), which does nothing.
Then you keep all your try catch, if you do whatever you want in the
catch block, but at the end, you re 

 ' throw new RootException("with your description in it") '
Now your global exception handler will handle the RootException with
details in it. 
Don't know if it helps, but that's what we do.

Rgds.
Pat

-----Original Message-----
From: Frank Burns [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 18, 2004 5:29 AM
To: [EMAIL PROTECTED]
Subject: Re: Help with using declarative error handling


Thanks for your reply, Bill.

I already appreciate the point you are making,

However, the problem I am trying to solve is that my AuthenticateAction
class can throw the TRCDatabaseException in SEVERAL places.

The example you provide will display the same error message for ALL
TRCDatabaseExceptions that occur in my Action class.

I want to be able to display a DIFFERENT error message for each place in
the code where the exception can occur.

Hence my attempted solution -- which doesn't work.

Any ideas?

Thanks,

Frank.

----- Original Message ----- 
From: "Bill Schneider" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 17, 2004 1:18 PM
Subject: Re: Help with using declarative error handling


> Hi,
>
> try changing the exception handler in struts-config.xml to
>
> <exception
>        key="errors.database.noconnection"
>        type="mydomain.exception.TrcDatabaseException"
>        path="/common/exceptionTrcDatabase.jsp"
>        />
>
> You can get rid of the whole catch block in your action--the 
> ActionServlet takes care of it.  That's the beauty of declarative 
> exceptions.
>
> -- Bill
>
>
>   >> Wherever an exception is thrown in AuthenticateAction, I add some

> code in
>   >> the catch block, before rethrowing it, for example like this:
>   >>
>   >>   } catch(TrcDatabaseException ex){
>   >>    /* add relevant action errors */
>   >>    ActionErrors errors = new ActionErrors();
>   >>    errors.add(ActionErors.GLOBAL_ERROR, new
>   >> ActionError("errors.database.noconnection"));
>   >>    saveErrors(request, errors);
>   >>    /* rethrow the exception to be caught by Struts declarative
> exception
>   >> handling mechanism */
>   >>    throw ex;
>   >>   }
>   >>
>   >> I have also placed an errors.database.noconnection in the 
> resource file.
>   >>
>   >> In the struts-config file, for the AuthenticateAction, I have 
> defined an
>   >> exception element:
>   >>
>   >> <exception
>   >>     key="errors.generalmessage"
>   >>     type="mydomain.exception.TrcDatabaseException"
>   >>     path="/common/exceptionTrcDatabase.jsp"
>   >>     />
>   >>
>   >> I have created a JSP, exceptionTrcDatabase.jsp, that contains 
> this
> element:
>   >>
>   >>     <html:errors/>
>   >>
>   >> However, whenever I test this code (by deliberately creating the
> relevant
>   >> error conditions), only the errors.generalmessage is displayed.
>   >>
>   >> Why isn't the errors.database.noconnection being displayed as
well?
>
> -- Bill Schneider Chief Architect Vecna Technologies, Inc. 5004 Lehigh

> Road, Suite B College Park, MD 20740 [EMAIL PROTECTED] t: 
> 301-864-7594 f: 301-699-3180
> --
> Bill Schneider
> Chief Architect
>
> Vecna Technologies, Inc.
> 5004 Lehigh Road, Suite B
> College Park, MD 20740
> [EMAIL PROTECTED]
> t: 301-864-7594
> f: 301-699-3180
>
>
> ---------------------------------------------------------------------
> 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