01: package com.mockrunner.struts;
02:
03: import javax.servlet.http.HttpServletRequest;
04: import javax.servlet.http.HttpServletResponse;
05:
06: import org.apache.struts.action.ActionForm;
07: import org.apache.struts.action.ActionMapping;
08:
09: /**
10: * Generic interface for exception handlers. The default implementation
11: * is {@link DefaultExceptionHandlerConfig} and uses the Struts
12: * exception handling mechanism. In special cases, you may provide your own
13: * implementations of this interface, that may be independent from
14: * the Struts exception handling mechanism.
15: * Exception handler are called if an action throws an exception.
16: * Use {@link ActionTestModule#addExceptionHandler} to register an exception handler.
17: */
18: public interface ExceptionHandlerConfig {
19: /**
20: * Returns if this handler is able to handle the exception.
21: * @return <code>true</code> if this handler is able to handle the exception,
22: * <code>false</code> otherwise
23: */
24: public boolean canHandle(Exception exception);
25:
26: /**
27: * Handles the exception.
28: * @param exception the exception
29: * @param mapping the current <code>ActionMapping</code>
30: * @param form the current <code>ActionForm</code>
31: * @param request the current request
32: * @param response the current response
33: * @return the handler return value, usually an <code>ActionForward</code>,
34: * but may be any object
35: */
36: public Object handle(Exception exception, ActionMapping mapping,
37: ActionForm form, HttpServletRequest request,
38: HttpServletResponse response) throws Exception;
39: }
|