@Test public void toResponse() { final Throwable exception = new Exception("Ouch"); final Response result = exceptionMapper.toResponse(exception); assertThat(result.getStatus()).isEqualTo(500); assertThat(result.getEntity()).isEqualTo("Ouch"); }
@Override public Response toResponse(final Throwable ex) { final Throwable rootCause = ExceptionUtils.getRootCause(ex); final Throwable cause = (rootCause == null) ? ex : rootCause; LOGGER.error("Error occurred: {}. Root cause: {}", ex.getMessage(), cause.getMessage()); LOGGER.debug(null, ex); LOGGER.debug(null, cause); return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity(cause.getMessage()) .type(MediaType.TEXT_PLAIN) .build(); }
DefaultExceptionMapper implements ExceptionMapper<Throwable> { @Override public Response toResponse(final Throwable ex) { final Throwable rootCause = ExceptionUtils.getRootCause(ex); final Throwable cause = (rootCause == null) ? ex : rootCause; LOGGER.error("Error occurred: {}. Root cause: {}", ex.getMessage(), cause.getMessage()); LOGGER.debug(null, ex); LOGGER.debug(null, cause); return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity(cause.getMessage()) .type(MediaType.TEXT_PLAIN) .build(); } }
DefaultExceptionMapper implements ExceptionMapper<Throwable> { @Override public Response toResponse(final Throwable ex) { final Throwable rootCause = ExceptionUtils.getRootCause(ex); final Throwable cause = (rootCause == null) ? ex : rootCause; LOGGER.error("Error occurred: {}. Root cause: {}", ex.getMessage(), cause.getMessage()); LOGGER.debug(null, ex); LOGGER.debug(null, cause); return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity(cause.getMessage()) .type(MediaType.TEXT_PLAIN) .build(); }  }
DefaultExceptionMapper implements ExceptionMapper<Throwable> { @Override public Response toResponse(final Throwable ex) { final Throwable rootCause = ExceptionUtils.getRootCause(ex); final Throwable cause = (rootCause == null) ? ex : rootCause; LOGGER.error("Error occurred: {}. Root cause: {}", ex.getMessage(), cause.getMessage()); LOGGER.debug(null, ex); LOGGER.debug(null, cause); return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity(cause.getMessage()) .type(MediaType.TEXT_PLAIN) .build(); }  @Override Response toResponse(final Throwable ex); }
DefaultExceptionMapper implements ExceptionMapper<Throwable> { @Override public Response toResponse(final Throwable ex) { final Throwable rootCause = ExceptionUtils.getRootCause(ex); final Throwable cause = (rootCause == null) ? ex : rootCause; LOGGER.error("Error occurred: {}. Root cause: {}", ex.getMessage(), cause.getMessage()); LOGGER.debug(null, ex); LOGGER.debug(null, cause); return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity(cause.getMessage()) .type(MediaType.TEXT_PLAIN) .build(); }  @Override Response toResponse(final Throwable ex);  }