Exception Handlers

Exception handlers implement the de.odysseus.calyxo.control.Filter interface. The controller instantiates one instance per exception handler configuration. After instantiation, the controller gives an exception handler the opportunity to do some initialization by calling its

public void init(
  ExceptionHandlerConfig config,
  ModuleContext context) throws Exception;

method. The de.odysseus.calyxo.control.conf.ExceptionHandlerConfig interface reflects the handler's configuration and provides methods to access its parameters.

Exception handlers may be declared for a hierarchy of exception classes either local to an action or global to the module. See the section on exception handler configuration for details.

If an action's invocation throws an exception, the module searches for an exception handler as follows: for each class cls on the inheritance path from the exception's class up to java.lang.Exception, the module first checks for a local, then for or global exception handler, that has been declared for the current class cls. On the first one it finds, it calls the

public DispatchConfig handle(
  HttpServletRequest request,
  HttpServletResponse response,
  ActionConfig actionConfig,
  Exception exception) throws IOException, ServletException;

method. The actionConfig parameter corresponds to the action, that threw the exception. The handler is responsible to answer a dispatch configuration.

If the module didn't find a matching exception handler it wraps the exception into a ServletException and throws it again. Similar, an exception, thrown in an exception handler's handler() method is not caught by the module and will go up to the servlet container.