class HttpErrorHandlerResolverImpl implements HttpErrorHandlerResolver {

    @Override
    public HttpErrorHandler getHandler(final RuntimeException e) {
        Throwable fallbackException;

        try {
            if (e instanceof ProtocolException) {
                return getProtocolExceptionHandler((ProtocolException) e);
            } else if (e instanceof AccessDeniedException) {
                return new HttpError403Handler(serverConfig.getErrorDocument403Path());
            } else if (e instanceof NotFoundException) {
                Statistics.incrementError404();
                return new HttpError404Handler(serverConfig.getErrorDocument404Path());
            } else if (e instanceof MethodNotAllowedException) {
                return new HttpError405Handler(getAllowedMethods());
            } else {
                fallbackException = e;
            }
        } catch (Throwable handlingException) {
            fallbackException = handlingException;
        }

        Statistics.incrementError500();
        return new HttpError500Handler().setReason(fallbackException);
    }

    public  HttpErrorHandlerResolverImpl(final ServerConfig serverConfig);

}