@Test public void toResponse() { final Throwable cause = new Exception("OUCH"); final DecodingException decodingException = new DecodingException(cause); final Response result = instance.toResponse(decodingException); assertThat(result).isNotNull(); final String message = result.getEntity().toString(); assertThat(message).isEqualTo("java.lang.Exception: OUCH"); assertThat(result.getStatus()).isEqualTo(400); }
@Override public Response toResponse(final DecodingException exception) { LOGGER.warn("Failed to decode message: {}", exception.getMessage()); LOGGER.debug(null, exception); return Response.status(Response.Status.BAD_REQUEST) .entity(exception.getMessage()) .type(MediaType.TEXT_PLAIN) .build(); }
DecodingExceptionMapper implements ExceptionMapper<DecodingException> { @Override public Response toResponse(final DecodingException exception) { LOGGER.warn("Failed to decode message: {}", exception.getMessage()); LOGGER.debug(null, exception); return Response.status(Response.Status.BAD_REQUEST) .entity(exception.getMessage()) .type(MediaType.TEXT_PLAIN) .build(); } }
DecodingExceptionMapper implements ExceptionMapper<DecodingException> { @Override public Response toResponse(final DecodingException exception) { LOGGER.warn("Failed to decode message: {}", exception.getMessage()); LOGGER.debug(null, exception); return Response.status(Response.Status.BAD_REQUEST) .entity(exception.getMessage()) .type(MediaType.TEXT_PLAIN) .build(); }  }
DecodingExceptionMapper implements ExceptionMapper<DecodingException> { @Override public Response toResponse(final DecodingException exception) { LOGGER.warn("Failed to decode message: {}", exception.getMessage()); LOGGER.debug(null, exception); return Response.status(Response.Status.BAD_REQUEST) .entity(exception.getMessage()) .type(MediaType.TEXT_PLAIN) .build(); }  @Override Response toResponse(final DecodingException exception); }
DecodingExceptionMapper implements ExceptionMapper<DecodingException> { @Override public Response toResponse(final DecodingException exception) { LOGGER.warn("Failed to decode message: {}", exception.getMessage()); LOGGER.debug(null, exception); return Response.status(Response.Status.BAD_REQUEST) .entity(exception.getMessage()) .type(MediaType.TEXT_PLAIN) .build(); }  @Override Response toResponse(final DecodingException exception);  }