This patch prints file name of currently parsed document
if an parse error occurs. While parsing XML documments from
string, user may specify NULL as URL and the original error message
(not containing filename information) is printed.

Fixes BZ #726771
---
 src/util/xml.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/util/xml.c b/src/util/xml.c
index 05317ea..48fc3cf 100644
--- a/src/util/xml.c
+++ b/src/util/xml.c
@@ -647,10 +647,18 @@ catchXMLError(void *ctx, const char *msg 
ATTRIBUTE_UNUSED, ...)
         if (virGetLastError() == NULL &&
             ctxt->lastError.level == XML_ERR_FATAL &&
             ctxt->lastError.message != NULL) {
-            virGenericReportError(domcode, VIR_ERR_XML_DETAIL,
-                                  _("at line %d: %s"),
-                                  ctxt->lastError.line,
-                                  ctxt->lastError.message);
+            if (ctxt->lastError.file) {
+                virGenericReportError(domcode, VIR_ERR_XML_DETAIL,
+                                      _("%s:%d: %s"),
+                                      ctxt->lastError.file,
+                                      ctxt->lastError.line,
+                                      ctxt->lastError.message);
+            } else {
+                virGenericReportError(domcode, VIR_ERR_XML_DETAIL,
+                                      _("at line %d: %s"),
+                                      ctxt->lastError.line,
+                                      ctxt->lastError.message);
+            }
         }
     }
 }
-- 
1.7.3.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to