Class ExceptionHandler

  • All Implemented Interfaces:
    HttpHandler

    public class ExceptionHandler
    extends java.lang.Object
    implements HttpHandler
    Handler that dispatches to a given handler and allows mapping exceptions to be handled by additional handlers. The order the exception handlers are added is important because of inheritance. Add all child classes before their parents in order to use different handlers.
    • Field Detail

      • THROWABLE

        public static final AttachmentKey<java.lang.Throwable> THROWABLE
    • Constructor Detail

      • ExceptionHandler

        public ExceptionHandler​(HttpHandler handler)
    • Method Detail

      • handleRequest

        public void handleRequest​(HttpServerExchange exchange)
                           throws java.lang.Exception
        Description copied from interface: HttpHandler
        Handle the request.
        Specified by:
        handleRequest in interface HttpHandler
        Parameters:
        exchange - the HTTP request/response exchange
        Throws:
        java.lang.Exception
      • addExceptionHandler

        public <T extends java.lang.Throwable> ExceptionHandler addExceptionHandler​(java.lang.Class<T> clazz,
                                                                                    HttpHandler handler)