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

[libvirt] [PATCH 2/4] New error code VIR_ERR_XML_CONFIG



Up to now developers didn't know which error code to use, when invalid
attribute/element value was given (e.g. string when expecting integer),
something was missing, etc. This patch creates a new error code for
cases like that.

VIR_ERR_XML_ERROR should really be used when given XML is invalid,
meaning bad syntax, or not well formed.
---
 include/libvirt/virterror.h |    1 +
 src/util/virterror.c        |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 0708e02..2f160c9 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -231,6 +231,7 @@ typedef enum {
     VIR_ERR_INVALID_DOMAIN_SNAPSHOT = 71,/* invalid domain snapshot */
     VIR_ERR_NO_DOMAIN_SNAPSHOT = 72,	/* domain snapshot not found */
     VIR_ERR_INVALID_STREAM = 73,        /* stream pointer not valid */
+    VIR_ERR_XML_CONFIG = 74,            /* invalid or not well formed input XML*/
 } virErrorNumber;
 
 /**
diff --git a/src/util/virterror.c b/src/util/virterror.c
index 2d7309a..f044dc1 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -1205,6 +1205,12 @@ virErrorMsg(virErrorNumber error, const char *info)
             else
                 errmsg = _("invalid stream pointer in %s");
             break;
+        case VIR_ERR_XML_CONFIG:
+            if (info == NULL)
+                errmsg = _("XML parsing error: document not well formed or invalid");
+            else
+                errmsg = _("XML parsing error: %s");
+            break;
     }
     return (errmsg);
 }
-- 
1.7.5.rc3


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