ViewServlet extends HttpServlet { @VisibleForTesting void dispatchAndSend(final Request request, final ViewFacet facet, final HttpResponseSender sender, final HttpServletResponse httpResponse) throws Exception { Response response = null; Exception failure = null; try { response = facet.dispatch(request); } catch (Exception e) { failure = e; } String describeFlags = request.getParameters().get(P_DESCRIBE); log.trace("Describe flags: {}", describeFlags); if (describeFlags != null) { send(request, describe(request, response, failure, describeFlags), httpResponse); } else { if (failure != null) { throw failure; } log.debug("Request: {}", request); sender.send(request, response, httpResponse); } } @Inject  ViewServlet(final RepositoryManager repositoryManager,
                     final HttpResponseSenderSelector httpResponseSenderSelector,
                     final DescriptionHelper descriptionHelper,
                     final DescriptionRenderer descriptionRenderer,
                     @Named("${nexus.repository.sandbox.enable:-true}") final boolean sandboxEnabled); @Override void init(final ServletConfig config); @Override void destroy();  }
@Test(expected = RuntimeException.class) public void facetExceptionsReturnedNormally() throws Exception { descriptionRequested(null); facetThrowsException(true); underTest.dispatchAndSend(request, facet, defaultResponseSender, servletResponse); }