code: public String getJsonError(ODataException exception) throws ODataRenderException {
          checkNotNull(exception);
  
          LOG.debug("Start building Json error document");
  
          ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  
          try {
              JsonGenerator jsonGenerator = JSON_FACTORY.createGenerator(outputStream, JsonEncoding.UTF8);
              jsonGenerator.writeStartObject();
  
              jsonGenerator.writeObjectFieldStart(ERROR);
  
              jsonGenerator.writeStringField(CODE, String.valueOf(exception.getCode().getCode()));
              jsonGenerator.writeStringField(MESSAGE, String.valueOf(exception.getMessage()));
              // optional
              if (exception.getTarget() != null) {
                  jsonGenerator.writeStringField(TARGET, String.valueOf(exception.getTarget()).replace("\"", "'"));
              }
              jsonGenerator.writeEndObject();
              jsonGenerator.close();
  
              return outputStream.toString();
          } catch (IOException e) {
              LOG.error("Not possible to write error JSON.");
              throw new ODataRenderException("Not possible to write error JSON: ", e);
          }
      }
docs: Gets the json error output according to ODataException.
  
  @param exception ODataException
  @return errorJsonResponse
  @throws ODataRenderException If unable to render the json error message