Google
  Web www.spinics.net

[PATCH 1/2] xml: Print file name on parse error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

Powered by Linux

Google
  Web www.spinics.net