You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Paul Benedict (JIRA)" <ji...@apache.org> on 2006/11/26 06:38:57 UTC

[jira] Updated: (STR-2499) Throw exception when forward not found

     [ http://issues.apache.org/struts/browse/STR-2499?page=all ]

Paul Benedict updated STR-2499:
-------------------------------

    Bugzilla Id:   (was: 35361)
    Component/s: Core
                     (was: Unknown)
       Assignee:     (was: Struts Developers)

> Throw exception when forward not found
> --------------------------------------
>
>                 Key: STR-2499
>                 URL: http://issues.apache.org/struts/browse/STR-2499
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: Future
>         Environment: Operating System: All
> Platform: All
>            Reporter: Frank W. Zammetti
>            Priority: Minor
>
> 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

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira