Adds proper exception handling during calling action
This will allow ExceptionHandler to work


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/3b9d5861
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/3b9d5861
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/3b9d5861

Branch: refs/heads/master
Commit: 3b9d58614f0ad192da8bffa657b820c28cdaa1ef
Parents: 4f4f526
Author: Lukasz Lenart <lukaszlen...@apache.org>
Authored: Tue Sep 23 21:44:50 2014 +0200
Committer: Lukasz Lenart <lukaszlen...@apache.org>
Committed: Tue Sep 23 21:44:50 2014 +0200

----------------------------------------------------------------------
 .../xwork2/DefaultActionInvocation.java             | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/3b9d5861/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
----------------------------------------------------------------------
diff --git 
a/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java 
b/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
index 4539e56..dd44b14 100644
--- 
a/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
+++ 
b/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
@@ -28,6 +28,8 @@ import com.opensymphony.xwork2.util.ValueStackFactory;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
+import ognl.MethodFailedException;
+import ognl.NoSuchPropertyException;
 import ognl.OgnlException;
 
 import java.util.ArrayList;
@@ -439,17 +441,23 @@ public class DefaultActionInvocation implements 
ActionInvocation {
                 }
             }
             return saveResult(actionConfig, methodResult);
-        } catch (OgnlException e) {
+        } catch (NoSuchPropertyException e) {
+            throw new IllegalArgumentException("The " + methodName + "() is 
not defined in action " + getAction().getClass() + "");
+        } catch (MethodFailedException e) {
             // We try to return the source exception.
-            //Throwable t = e.getTargetException();
+            Throwable t = e.getCause();
 
             if (actionEventListener != null) {
-                String result = actionEventListener.handleException(e, 
getStack());
+                String result = actionEventListener.handleException(t, 
getStack());
                 if (result != null) {
                     return result;
                 }
             }
-            throw e;
+            if (t instanceof Exception) {
+                throw (Exception) t;
+            } else {
+                throw e;
+            }
         } finally {
             UtilTimerStack.pop(timerKey);
         }

Reply via email to