@Test public void otherCauseGets500() { final RuntimeException cause = new RuntimeException("OtherMessage message"); final WebApplicationException exception = new WebApplicationException(cause); final Response response = mapper.toResponse(exception); assertThat(response.getStatus()).isEqualTo(500); }
@Override public Response toResponse(final WebApplicationException exception) { LOGGER.debug("{}", exception.getClass()); LOGGER.debug("{}", exception.getCause() == null ? "No cause" : exception.getCause().getClass()); LOGGER.warn("{}", exception.getMessage()); final Response.Status returnStatus; try { throw exception.getCause(); } catch (final UnmarshalException ex) { LOGGER.warn("Unable to unmarshal payload"); returnStatus = Response.Status.BAD_REQUEST; } catch (final Throwable ex) { returnStatus = Response.Status.INTERNAL_SERVER_ERROR; } return Response.status(returnStatus).entity(exception.getMessage()).type(MediaType.TEXT_PLAIN).build(); }
WebApplicationExceptionMapper implements ExceptionMapper<WebApplicationException> { @Override public Response toResponse(final WebApplicationException exception) { LOGGER.debug("{}", exception.getClass()); LOGGER.debug("{}", exception.getCause() == null ? "No cause" : exception.getCause().getClass()); LOGGER.warn("{}", exception.getMessage()); final Response.Status returnStatus; try { throw exception.getCause(); } catch (final UnmarshalException ex) { LOGGER.warn("Unable to unmarshal payload"); returnStatus = Response.Status.BAD_REQUEST; } catch (final Throwable ex) { returnStatus = Response.Status.INTERNAL_SERVER_ERROR; } return Response.status(returnStatus).entity(exception.getMessage()).type(MediaType.TEXT_PLAIN).build(); } }
WebApplicationExceptionMapper implements ExceptionMapper<WebApplicationException> { @Override public Response toResponse(final WebApplicationException exception) { LOGGER.debug("{}", exception.getClass()); LOGGER.debug("{}", exception.getCause() == null ? "No cause" : exception.getCause().getClass()); LOGGER.warn("{}", exception.getMessage()); final Response.Status returnStatus; try { throw exception.getCause(); } catch (final UnmarshalException ex) { LOGGER.warn("Unable to unmarshal payload"); returnStatus = Response.Status.BAD_REQUEST; } catch (final Throwable ex) { returnStatus = Response.Status.INTERNAL_SERVER_ERROR; } return Response.status(returnStatus).entity(exception.getMessage()).type(MediaType.TEXT_PLAIN).build(); }  }
WebApplicationExceptionMapper implements ExceptionMapper<WebApplicationException> { @Override public Response toResponse(final WebApplicationException exception) { LOGGER.debug("{}", exception.getClass()); LOGGER.debug("{}", exception.getCause() == null ? "No cause" : exception.getCause().getClass()); LOGGER.warn("{}", exception.getMessage()); final Response.Status returnStatus; try { throw exception.getCause(); } catch (final UnmarshalException ex) { LOGGER.warn("Unable to unmarshal payload"); returnStatus = Response.Status.BAD_REQUEST; } catch (final Throwable ex) { returnStatus = Response.Status.INTERNAL_SERVER_ERROR; } return Response.status(returnStatus).entity(exception.getMessage()).type(MediaType.TEXT_PLAIN).build(); }  @Override Response toResponse(final WebApplicationException exception); }
WebApplicationExceptionMapper implements ExceptionMapper<WebApplicationException> { @Override public Response toResponse(final WebApplicationException exception) { LOGGER.debug("{}", exception.getClass()); LOGGER.debug("{}", exception.getCause() == null ? "No cause" : exception.getCause().getClass()); LOGGER.warn("{}", exception.getMessage()); final Response.Status returnStatus; try { throw exception.getCause(); } catch (final UnmarshalException ex) { LOGGER.warn("Unable to unmarshal payload"); returnStatus = Response.Status.BAD_REQUEST; } catch (final Throwable ex) { returnStatus = Response.Status.INTERNAL_SERVER_ERROR; } return Response.status(returnStatus).entity(exception.getMessage()).type(MediaType.TEXT_PLAIN).build(); }  @Override Response toResponse(final WebApplicationException exception);  }