You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by shanku <sh...@gmail.com> on 2009/07/24 18:05:16 UTC
Issue with custom ExceptionMappingInterceptor
I have implemented a custom ExceptionMappingInterceptor. The custom
interceptor basically handles all the business exceptions thrown by the
service method. The one that implemented is getting executed fine whenever a
exception is throw however on broswer i cant see the same page and error
msg, where as i see the stack trace of exception...
I can see all the sysout messages on my console.
Please help me.
public class MyExceptionInterceptor extends ExceptionMappingInterceptor {
protected void publishException(ActionInvocation actionInvocation,
ExceptionHolder exceptionHolder) {
System.out.println("********************start
publishException**********************");
super.publishException(actionInvocation, exceptionHolder);
// ActionContext invocationContext = actionInvocation
// .getInvocationContext();
if (exceptionHolder.getException() instanceof
MyBusinessException) {
MyBusinessException mecoBusinessException =
(MyBusinessException) exceptionHolder.getException();
Object action = actionInvocation.getAction();
System.out.println("*********** instanceof
MyBusinessException ******* ");
if (action instanceof ValidationAware) {
System.out.println("****** instanceof ValidationAware
******** ");
ValidationAware va = (ValidationAware)
action;
String key =
myBusinessException.getErrorCode().getCode();
String message = "";
System.out.println("********KEY: "+key);
if (actionInvocation.getAction() instanceof
ActionSupport) {
System.out.println("******** instanceof
ActionSupport ******* ");
message = ((ActionSupport)
actionInvocation.getAction())
.getText(key);
System.out.println("******* instanceof ActionSupport
message*** "+message);
} else {
message = key;
}
// va.addActionError(message);
va.addActionError("INTERCEPTOR CALLED TO
PRINT ERROR CODE>>>>>>>>");
}
}
System.out.println("************************** end publishException
***********************");
}
}
my struts config:
</interceptors>
<interceptor name="myExceptionInterceptor"
class="com.xxx.yyy.web.interceptor.MyExceptionInterceptor">
</interceptor>
<interceptor-stack name="myExceptionStack">
<interceptor-ref name="defaultStack" />
<interceptor-ref
name="myExceptionInterceptor" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="myExceptionStack" />
-----------------------
Thanks in advance
--
View this message in context: http://www.nabble.com/Issue-with-custom-ExceptionMappingInterceptor-tp24647296p24647296.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org