Interface ExceptionHandler

  • All Known Implementing Classes:
    LoggingExceptionHandler

    public interface ExceptionHandler
    An exception handler allows you to perform custom actions when an exception propagates out of the servlet handler chain. The default handler will simply log the exception, however it is possible to write custom handlers to handle the error however you want. A common use for this would be to change the log format for exceptions, or possibly suppress the logging for certain exceptions types.

    Implementations of this interface may also choose to suppress error page handler, and handle error page generation internally by returning true

    Author:
    Stuart Douglas
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean handleThrowable​(io.undertow.server.HttpServerExchange exchange, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, java.lang.Throwable throwable)
      Handles an exception.
    • Method Detail

      • handleThrowable

        boolean handleThrowable​(io.undertow.server.HttpServerExchange exchange,
                                jakarta.servlet.ServletRequest request,
                                jakarta.servlet.ServletResponse response,
                                java.lang.Throwable throwable)
        Handles an exception. If this method returns true then the request/response cycle is considered to be finished, and no further action will take place, if this returns false then standard error page redirect will take place. The default implementation of this simply logs the exception and returns false, allowing error page and async context error handling to proceed as normal.
        Parameters:
        exchange - The exchange
        request - The request
        response - The response
        throwable - The exception
        Returns:
        true true if the error was handled by this method