At 1:58 AM +0100 5/18/04, Frank Burns wrote:

This seems simple enough. So why doesn't it work?

Because the default ExceptionHandler class saves its own error messages into the request under the same key that Action.saveErrors() uses, overwriting the reference to the errors that you saved.


http://jakarta.apache.org/struts/api/org/apache/struts/action/ExceptionHandler.html#storeException(javax.servlet.http.HttpServletRequest,%20java.lang.String,%20org.apache.struts.action.ActionError,%20org.apache.struts.action.ActionForward,%20java.lang.String)




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.

--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "Imagine if every Thursday your shoes exploded if you tied them the usual way. This happens to us all the time with computers, and nobody thinks of complaining."
-- Jef Raskin


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



Reply via email to