History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: WW-598
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Not A Problem
Priority: Minor Minor
Assignee: Matthew Porter
Reporter: Matt Raible
Votes: 2
Watchers: 5
Operations

If you were logged in you would be able to see more operations.
WebWork

Add ability to map exceptions to pages (or actions)

Created: 21/Jul/04 10:40 AM   Updated: 10/Feb/07 08:27 AM
Component/s: Interceptors
Affects Version/s: None
Fix Version/s: None

Issue Links:
Duplicate
 
This issue is duplicated by:
WW-39 WW needs generalized error handling i... Major Closed
WW-558 Exception Handler Interceptor and Exc... Major Closed
Related
This issue relates to:
WW-558 Exception Handler Interceptor and Exc... Major Closed
XW-115 Exception handler mechanism Major Closed
 


 Description  « Hide
Struts and Spring MVC both have the ability to map a particular exception to a particular page. Struts goes a bit further and allows you to map an exception to an ExceptionHandler - allowing the user to wrap Exceptions in ActionErrors and return the user to where they came from (i.e. the INPUT).

I'd be nice to have a similar feature in WebWork. Struts allows you to specify this at a global level or at an action level. Spring is simply a global level.

Spring Example:

<bean id="exceptionResolver"
        class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
        <property name="exceptionMappings">
            <props>
                <prop key="org.springframework.dao.DataAccessException">
                    dataAccessFailure
                </prop>
            </props>
        </property>
    </bean>

Struts Example:

<exception
        key="exception.database.error"
        type="net.reumann.DatabaseException"
        path="/dataAccessFailure.jsp"/>

I have a sample app I can quickly and easily test this functionality with.

 All   Comments   Change History      Sort Order:
Eric Hauser - [21/Jul/04 11:28 AM ]
Struts also has a nice feature that allows you to declare a handler for an exception. This is a nice feature since it allows you some flexability on what you want to do with the exception, instead of just forwarding the exception to a page.

Patrick Lightbody - [21/Jul/04 03:57 PM ]
I don't see why we need this if you can already do it in web.xml -- provided that WebWork throws the source exception out to the container. If it doesn't, we might want to fix that.

Eric Hauser - [11/Aug/04 10:07 AM ]
web.xml only allows you to assign a page to a particular exception or error code. This approach allows for you to do something programmatically when an error occurs (instead of hacking it into the JSP error page). Something I did in Struts was have it page me everytime a particular exception happened.

This same functionality can be implemented using an interceptor. What I do now is just wrap the action invocation in a try/catch block. Of course, then I have to check and make sure that the exception is of the right type I am trying to catch.

If xwork is supposed to be completely independent of the web container, then it seems to make sense to implement some sort of error handling in the framework. However, it doesn't seem like too many others are requesting this sort of feature =).

Matthew Porter - [13/Mar/05 12:43 PM ]
I have started to look at what it would take to implement this feature as we already have something similar inhouse. My thought is that an exception should map directly to another action, where the mapping is specified by actionName and namespace (similar to chaining). Unfortunately, this would seem to require a change to xwork.xml.

For some exceptions (such as a few in Acegi), I wonder if it should be possible to redirect back to the original action with the original stack.

Matthew Porter - [21/Mar/05 10:33 AM ]
These two issues are similar and will be addressed in XW 1.1/WW2.2

Patrick Lightbody - [03/Jul/05 01:40 PM ]
Jason -- see WW-558 for an ExceptionInterceptor that was provided. It might be useful.

Patrick Lightbody - [06/Aug/05 10:43 AM ]
Spoke with Matthew about this while he was in town. The plan is to add a generic interceptor to XWork and then add a new type of XML configuration for WebWork that makes it easier to do these types of common things. Ie: we'd add an <exception on="MyException">[some result]</exception> in webwork.xml, but that would really end up being just another interceptor placed at the end of the stack. That means we need both XW-115 and WW-598 open as they have different requirements.

Matthew Porter - [17/Aug/05 01:26 PM ]
Check XW-115 for how this is handled from a pure-XWork configuration. Patrick and I talked about having a simplified, more webwork-specific way to accomplish this. The XW-115 way will work in WW, though.

Tom Schneider - [10/Feb/07 08:27 AM ]
With the current webwork error handling capabilities, you should be able to accomplish this--even if a custom error handling interceptor is needed.