Page tree
Skip to end of metadata
Go to start of metadata

Draft for 4.5.x

Filter exception handler

See  MAGNOLIA-3595 - Getting issue details... STATUS


Right now only way how to handle exceptions thrown by filter is to extend the specific filter and catch the exception in custom class. We should provide a way how to configure exception handler to any filter.


New interface - ExceptionHandler

set/get exception list

set/is enabled

void handle(Exception) method

Example implementation of EH - registered exception will be caught and logged under level set with the exception (LoggingExceptionHandler).

ExceptionHandler will be part of AbstractMgnlFilter. If filter have some handler configured all exceptions are caught (doFilter() method in MgnlFilterChain class will by in try block). Catch block then searches if caught exception has some behaviour configured. If yes then will follow this, if not then exception is re-thrown.

Example handler should contain settings if exact exceptions should be treated or if also sub-classes of this exception should be included. Then the level of logging should be set so caught exceptions can be treated accordingly.

  • No labels


  1. While looking at the recent CSRF fixes, I figured this could be _almost_ already implemented via the SecurityCallbackFilter and HttpClientCallback. Granted, naming isn't great, and maybe we'd want an additional method, such as boolean accepts(Throwable t) on HttpClientCallback, but the logic is really the same !

  2. Alternative idea (close to what's proposed in MAGNOLIA-3595 I think) is to have a filter dedicated to exception handling, at the top of the chain:

    public void doFilter(req,res,chain) {
      try {
      } catch (Throwable t) {

    If we have multi-binding, it could become trivial to inject all known exception handlers.