Since I see no reason to define hundreds of different exceptions, which are very similar in their nature and are handled in a similar way, I would propose:
*) introduce 2 base exception classes: AppException and RuntimeException which should support constructors like: AppException("error.password.mismatch"); AppException("database.load", "myDatabase"); with entries in application properties error.password.mismatch=<li>Invalid username and/or password, please try again</li> database.load=Cannot load database from {0} *) extend Laine's approach with following configuration option: <global-exceptions> <exception type="org.apache.struts.exceptions.AppException"/> <exception type="org.apache.struts.exceptions.RuntimeException" path="error.jsp"/> </global-exceptions> - you would stay on the same page in case of all application exceptions - you would be forwarded to error.jsp in case of runtime exceptions - hadling of some particular exception can be added as well If the exeption key is specified, then the handling will be as Laine has proposed. If no exception key is specified, then the exception.getMessage() will be used as a key for a lookup. exception.getValues() returns the array of values which can be passed to messages.getMessage(): MessageResources messages = MessageResources.getMessageResources("Exceptions"); messages.getMessage(super.getMessage(), values); This stuff can be implemented within the basis exception class. If it is OK, then I can try to modify the code to introduce the changes. Laine, what do you think about ? >public class DispatchExceptionAction extends Action { > public ActionForward doPerform( > ActionMapping mapping, > ActionForm form, > HttpServletRequest request, > HttpServletResponse response) > throws Exception { > > // Override this class instead of perform > // and return ActionForwards in the > // usual way; but use with the alternative > // of ExceptionForwards instead of try catch > > return null; > } > public ActionForward perform( > ActionMapping mapping, > ActionForm form, > HttpServletRequest request, > HttpServletResponse response) > throws IOException, ServletException { > ActionForward forward = null; > try { > forward = doPerform(mapping,form,request,response); > } > catch (Exception e) { > > // Lookup exceptions here > // and set forward > // or .. > > throw new ServletException(e); > > } > > return forward; > } It would mean, that Action classes should derive not from action.Action, but from action.DispatchExceptionAction. It is exactly what we have done, while introducing our base action class. Personally I think, that it is quite wise to create such base action for your project. You can put some additional stuff in it, which can be usefull in your application. ActionServlet is also a candidat for deriving from. For example to configure log4j. >Later on, I would like to build this deeper into the framework, but >don't know how to manage the signature shift without breaking the >installed base. Perhaps a job for Struts 2 ... which might include a >signature updater ... perhaps some time later nobody will remind old perform(), but would use new execute() ;-) Dmitri Valdin -- Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>