You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Richard Wallace <rw...@thewallacepack.net> on 2007/05/17 19:24:42 UTC
Exceptions thrown in prepare() method ignored
Hello,
I have an action with a prepare method. The prepare method loads some
objects to operate on for the editing, so I have the interceptor stack
setup with the params, prepare, params interceptors. My prepare method is
public void prepareCreate () {
if (m_projectId == null) {
throw new IllegalArgumentException ("Project ID is missing.");
}
m_project = m_projectService.getProject (m_projectId);
if (m_project == null) {
throw new IllegalArgumentException ("No project with the
provided ID exists.");
}
So, if no project id is set or it's not a valid id, I want to show an
error page. Problem is the exception is caught and a warning is logged
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil.invokePrefixMethod(PrefixMethodInvocationUtil.java:111)
at
com.opensymphony.xwork2.interceptor.PrepareInterceptor.intercept(PrepareInterceptor.java:103)
at
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
at
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
at
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
With WebWork 2.2 the exception would be handled the same way as an
exception during action execution, so you could use the
<global-exception-mapping> and <global-results> to send users to an
error page.
Is this something that was overlooked or is there an alternate way to
accomplish this?
Thanks,
Rich
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org