code: public void writeError(ODataException exception) throws ODataRenderException {
  
          checkNotNull(exception);
  
          try {
              xmlWriter.writeStartElement(ODATA_METADATA_NS, ERROR);
              xmlWriter.writeNamespace(METADATA, ODATA_METADATA_NS);
              xmlWriter.writeStartElement(METADATA, ErrorRendererConstants.CODE, ODATA_METADATA_NS);
              xmlWriter.writeCharacters(String.valueOf(exception.getCode().getCode()));
              xmlWriter.writeEndElement();
              xmlWriter.writeStartElement(METADATA, ErrorRendererConstants.MESSAGE, ODATA_METADATA_NS);
              xmlWriter.writeCharacters(String.valueOf(exception.getMessage()));
              xmlWriter.writeEndElement();
              if (exception.getTarget() != null) {
                  xmlWriter.writeStartElement(METADATA, TARGET, ODATA_METADATA_NS);
                  xmlWriter.writeCharacters(String.valueOf(exception.getTarget()));
                  xmlWriter.writeEndElement();
              }
              xmlWriter.writeEndElement();
          } catch (XMLStreamException e) {
              LOG.error("Not possible to marshall error stream XML");
              throw new ODataRenderException("Not possible to marshall error stream XML: ", e);
          }
      }
docs: <p>
  Write an error for a given exception.
  </p>
  <p>
  <b>Note:</b> Make sure {@link XMLErrorResponseWriter#startDocument()}
  has been previously invoked to start the XML
  stream document, and {@link XMLErrorResponseWriter#endDocument()} is invoked after to end it.
  </p>
  
  @param exception The exception to write an error for. It can not be {@code null}.
  @throws ODataRenderException In case it is not possible to write to the XML stream.