Hi Wendy, Thanks for your reply. I know that what you suggest is a solution.
But I don't understand why what I originally tried doesn't work, which is to 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; } and have <html:errors/> display it in the JSP that is forwarded to. This seems simple enough. So why doesn't it work? Any ideas why it doesn't? Cheers, Frank ----- Original Message ----- From: "Wendy Smoak" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Tuesday, May 18, 2004 12:01 AM Subject: RE: Help with using declarative error handling > From: Frank Burns [mailto:[EMAIL PROTECTED] > However, the problem I am trying to solve is that my > AuthenticateAction > class can throw the TRCDatabaseException in SEVERAL places. > > I want to be able to display a DIFFERENT error message for > each place in the > code where the exception can occur. What about subclassing TRCDatabaseException and making different exceptions for the different bad things that can happen? For example, I have a generic "DAOException", and beneath that, RecordNotFoundException, RecordLockedException, etc. Then throw the exception that describes what really happened, and let Struts do its thing. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Hi, I can't get the relevant error message from the resources file to display when an exception is thrown. Can you please help? Here is the scenario: One of my Action classes, AuthenticateAction, can generate the same type of application-specific exception (TrcDatabaseException) at various points in its code. I want to display error-specific information for each place where the TrcDatabaseException can be thrown in the AuthenticateAction. 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? Thanks, Frank. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]