class 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();
    }

}