DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=35361>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=35361 Summary: Throw exception when forward not found Product: Struts Version: Unknown Platform: All OS/Version: All Status: NEW Severity: normal Priority: P3 Component: Unknown AssignedTo: dev@struts.apache.org ReportedBy: [EMAIL PROTECTED] Currently, when mapping.findForward() is called in an Action, and the named forward is not found (because of a typo, or perhaps because it is dynamically determined incorrectly), Struts returns null, which resuls in a blank page, and no indication to the developer about what went wrong. Someone, I forget who (sorry!) recently added some code to log a message in such a case, but that was after 1.2.7 was cut. That would be a step in the right direction, but I believe still not optimal. My feeling, echoed by some on the mailing lists, is that an exception should be thrown. The thinking is that such a situation really shouldn't happen in a production application, it should generally be a development-time problem, and as such should be easier to track down. Also, it is pretty much a showstopper kind of problem, i.e., not something an app would expect to recover from. As such, an exeption is probably more appropriate than just a log message. I propose the following change be made... in the ActionMapping class, alter the findForward() method as follows: /** * <p>Find and return the <code>ForwardConfig</code> instance defining * how forwarding to the specified logical name should be handled. This is * performed by checking local and then global configurations for the * specified forwarding configuration. If no forwarding configuration * can be found, return <code>null</code>.</p> * * @param name Logical name of the forwarding instance to be returned * @throws IllegalStateException If the forward is not found */ public ActionForward findForward(String name) throws IllegalStateException { ForwardConfig config = findForwardConfig(name); if (config == null) { config = getModuleConfig().findForwardConfig(name); } if (null == config) { throw new IllegalStateException("Forward not found: " + name); } return ((ActionForward) config); } Arguably there is a more appropriate exception type than IllegalStateException, and I have no problem if someone has a better suggestion. This is clearly a trivial change, but one I believe will make life easier on developers -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]