WebApplicationExceptionMapper implements ExceptionMapper<WebApplicationException> { @Override public Response toResponse(WebApplicationException e) { return status(e.getResponse().getStatus()).entity(new ErrorResponse(e.getMessage())).build(); }  @Override Response toResponse(WebApplicationException e);  }
@Test public void exceptionStatusAndMessageAreUsedInResponse() { try (Response response = mapper.toResponse(new WebApplicationException("error", BAD_REQUEST))) { assertThat(response.getStatus(), is(BAD_REQUEST.getStatusCode())); ErrorResponse error = (ErrorResponse) response.getEntity(); assertThat(error.error, is("error")); } }