public synchronized <T extends Exception> void exception(Class<T> exceptionClass, ExceptionHandler<? super T> handler) {
        // wrap
        ExceptionHandlerImpl wrapper = new ExceptionHandlerImpl<T>(exceptionClass) {
            @Override
            public void handle(T exception, Request request, Response response) {
                handler.handle(exception, request, response);
            }
        };

        exceptionMapper.map(exceptionClass, wrapper);
    }
Maps an exception handler to be executed when an exception occurs during routing

@param exceptionClass the exception class
@param handler        The handler
src/main/java/spark/Service.java