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); } HttpErrorHandlerResolverImpl(final ServerConfig serverConfig); @Override HttpErrorHandler getHandler(final RuntimeException e);  }
@Test public void shouldCaptureIntermediateExceptions() { ServerConfig serverConfig = null; HttpErrorHandlerResolver httpErrorHandlerResolver = new HttpErrorHandlerResolverImpl(serverConfig); HttpErrorHandler handler = httpErrorHandlerResolver.getHandler(new NotFoundException()); assertThat(handler, is(instanceOf(HttpError500Handler.class))); }