1 package org.javabb.interceptor; 2 3 import org.apache.commons.logging.Log; 4 import org.apache.commons.logging.LogFactory; 5 import org.javabb.action.infra.ActionSuper; 6 7 import com.opensymphony.xwork.Action; 8 import com.opensymphony.xwork.ActionInvocation; 9 import com.opensymphony.xwork.interceptor.Interceptor; 10 11 26 27 31 public class ExceptionInterceptor implements Interceptor { 32 33 protected final Log log = LogFactory.getLog(this.getClass()); 34 35 public void destroy() {} 36 public void init() {} 37 38 public String intercept(ActionInvocation actionInvocation) throws Exception { 39 ActionSuper action = (ActionSuper) actionInvocation.getAction(); 41 try { 42 return actionInvocation.invoke(); 43 } catch (Exception e) { 44 action.addActionError("Error: " + e.getMessage()); 45 log.error(e.getMessage(), e); 46 return Action.ERROR; 47 } 48 } 49 } 50 | Popular Tags |