@Test void testStatus() { try (Response response = this.tEM.toResponse(new WebApplicationException(404));) { assertThat(response.getStatus(), is(404)); } }
@Override public Response toResponse(Throwable t) { if (t instanceof WebApplicationException) { WebApplicationException webEx = (WebApplicationException) t; if(webEx.getResponse().getStatus() == 500) { this.logger.error("Internal server error while handling a request", webEx); } ResponseBuilder rb = Response.status(webEx.getResponse().getStatus()); String message = webEx.getLocalizedMessage(); if (webEx.getCause() != null) { message = message + " caused by " + webEx.getCause().toString(); } return rb.entity(message).type(MediaType.TEXT_PLAIN).build(); } ResponseBuilder rb = Response.status(Status.INTERNAL_SERVER_ERROR); String message = t.toString(); this.logger.error("Error while HTTP Request on the Server", t); return rb.entity(message).type(MediaType.TEXT_PLAIN).build(); }
ThrowableExceptionMapper implements ExceptionMapper<Throwable> { @Override public Response toResponse(Throwable t) { if (t instanceof WebApplicationException) { WebApplicationException webEx = (WebApplicationException) t; if(webEx.getResponse().getStatus() == 500) { this.logger.error("Internal server error while handling a request", webEx); } ResponseBuilder rb = Response.status(webEx.getResponse().getStatus()); String message = webEx.getLocalizedMessage(); if (webEx.getCause() != null) { message = message + " caused by " + webEx.getCause().toString(); } return rb.entity(message).type(MediaType.TEXT_PLAIN).build(); } ResponseBuilder rb = Response.status(Status.INTERNAL_SERVER_ERROR); String message = t.toString(); this.logger.error("Error while HTTP Request on the Server", t); return rb.entity(message).type(MediaType.TEXT_PLAIN).build(); } }
ThrowableExceptionMapper implements ExceptionMapper<Throwable> { @Override public Response toResponse(Throwable t) { if (t instanceof WebApplicationException) { WebApplicationException webEx = (WebApplicationException) t; if(webEx.getResponse().getStatus() == 500) { this.logger.error("Internal server error while handling a request", webEx); } ResponseBuilder rb = Response.status(webEx.getResponse().getStatus()); String message = webEx.getLocalizedMessage(); if (webEx.getCause() != null) { message = message + " caused by " + webEx.getCause().toString(); } return rb.entity(message).type(MediaType.TEXT_PLAIN).build(); } ResponseBuilder rb = Response.status(Status.INTERNAL_SERVER_ERROR); String message = t.toString(); this.logger.error("Error while HTTP Request on the Server", t); return rb.entity(message).type(MediaType.TEXT_PLAIN).build(); }  }
ThrowableExceptionMapper implements ExceptionMapper<Throwable> { @Override public Response toResponse(Throwable t) { if (t instanceof WebApplicationException) { WebApplicationException webEx = (WebApplicationException) t; if(webEx.getResponse().getStatus() == 500) { this.logger.error("Internal server error while handling a request", webEx); } ResponseBuilder rb = Response.status(webEx.getResponse().getStatus()); String message = webEx.getLocalizedMessage(); if (webEx.getCause() != null) { message = message + " caused by " + webEx.getCause().toString(); } return rb.entity(message).type(MediaType.TEXT_PLAIN).build(); } ResponseBuilder rb = Response.status(Status.INTERNAL_SERVER_ERROR); String message = t.toString(); this.logger.error("Error while HTTP Request on the Server", t); return rb.entity(message).type(MediaType.TEXT_PLAIN).build(); }  @Override Response toResponse(Throwable t); }
ThrowableExceptionMapper implements ExceptionMapper<Throwable> { @Override public Response toResponse(Throwable t) { if (t instanceof WebApplicationException) { WebApplicationException webEx = (WebApplicationException) t; if(webEx.getResponse().getStatus() == 500) { this.logger.error("Internal server error while handling a request", webEx); } ResponseBuilder rb = Response.status(webEx.getResponse().getStatus()); String message = webEx.getLocalizedMessage(); if (webEx.getCause() != null) { message = message + " caused by " + webEx.getCause().toString(); } return rb.entity(message).type(MediaType.TEXT_PLAIN).build(); } ResponseBuilder rb = Response.status(Status.INTERNAL_SERVER_ERROR); String message = t.toString(); this.logger.error("Error while HTTP Request on the Server", t); return rb.entity(message).type(MediaType.TEXT_PLAIN).build(); }  @Override Response toResponse(Throwable t);  }