@Test public void createsResponseWithStatus500AndUsesExceptionMessageAsEntity() { Exception exception = new Exception("<error message>"); Response response = exceptionMapper.toResponse(exception); assertEquals(500, response.getStatus()); assertEquals(TEXT_PLAIN_TYPE, response.getMediaType()); assertEquals(exception.getMessage(), response.getEntity()); }
@Override public Response toResponse(Exception exception) { String message = exception.getMessage(); if (message == null) { message = exception.getClass().getName(); } return Response .status(500) .entity(message) .type(MediaType.TEXT_PLAIN) .header(ExtHttpHeaders.JAXRS_BODY_PROVIDED, "Error-Message") .build(); }
DefaultExceptionMapper implements ExceptionMapper<Exception> { @Override public Response toResponse(Exception exception) { String message = exception.getMessage(); if (message == null) { message = exception.getClass().getName(); } return Response .status(500) .entity(message) .type(MediaType.TEXT_PLAIN) .header(ExtHttpHeaders.JAXRS_BODY_PROVIDED, "Error-Message") .build(); } }
DefaultExceptionMapper implements ExceptionMapper<Exception> { @Override public Response toResponse(Exception exception) { String message = exception.getMessage(); if (message == null) { message = exception.getClass().getName(); } return Response .status(500) .entity(message) .type(MediaType.TEXT_PLAIN) .header(ExtHttpHeaders.JAXRS_BODY_PROVIDED, "Error-Message") .build(); }  }
DefaultExceptionMapper implements ExceptionMapper<Exception> { @Override public Response toResponse(Exception exception) { String message = exception.getMessage(); if (message == null) { message = exception.getClass().getName(); } return Response .status(500) .entity(message) .type(MediaType.TEXT_PLAIN) .header(ExtHttpHeaders.JAXRS_BODY_PROVIDED, "Error-Message") .build(); }  @Override Response toResponse(Exception exception); }
DefaultExceptionMapper implements ExceptionMapper<Exception> { @Override public Response toResponse(Exception exception) { String message = exception.getMessage(); if (message == null) { message = exception.getClass().getName(); } return Response .status(500) .entity(message) .type(MediaType.TEXT_PLAIN) .header(ExtHttpHeaders.JAXRS_BODY_PROVIDED, "Error-Message") .build(); }  @Override Response toResponse(Exception exception);  }