diff options
author | David Sommerseth <davids@redhat.com> | 2009-05-04 10:39:02 +0200 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2009-05-04 10:39:02 +0200 |
commit | 1ccdf74b1e537c4bd747c079530a5d9ea904e138 (patch) | |
tree | 49eebffe831a35fd20b6547f8172f255e900093b /src/xmlpythonizer.c | |
parent | aad6b79d7363ea4fa1c1ce67a39848b13bdd19f4 (diff) | |
download | python-dmidecode-1ccdf74b1e537c4bd747c079530a5d9ea904e138.tar.gz python-dmidecode-1ccdf74b1e537c4bd747c079530a5d9ea904e138.tar.xz python-dmidecode-1ccdf74b1e537c4bd747c079530a5d9ea904e138.zip |
Improved error handling when parsing mapping XML
Diffstat (limited to 'src/xmlpythonizer.c')
-rw-r--r-- | src/xmlpythonizer.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/xmlpythonizer.c b/src/xmlpythonizer.c index 6287ea2..3c00f6b 100644 --- a/src/xmlpythonizer.c +++ b/src/xmlpythonizer.c @@ -243,13 +243,13 @@ ptzMAP *dmiMAP_ParseMappingXML(xmlDoc *xmlmap, const char *mapname) { // Verify that the root node got the right name if( (node == NULL) || (xmlStrcmp(node->name, (xmlChar *) "dmidecode_fieldmap") != 0 )) { - fprintf(stderr, "Invalid XML-Python mapping file\n"); + PyErr_SetString(PyExc_IOError, "Invalid XML-Python mapping file"); return NULL; } // Verify that it's of a version we support if( strcmp(dmixml_GetAttrValue(node, "version"), "1") != 0 ) { - fprintf(stderr, "Unsupported XML-Python mapping file format\n"); + PyErr_SetString(PyExc_IOError, "Unsupported XML-Python mapping file format"); return NULL; } @@ -264,8 +264,10 @@ ptzMAP *dmiMAP_ParseMappingXML(xmlDoc *xmlmap, const char *mapname) { } if( node == NULL ) { - fprintf(stderr, "No mapping for '%s' was found " - "in the XML-Python mapping file\n", mapname); + char msg[8194]; + snprintf(msg, 8193, "No mapping for '%s' was found " + "in the XML-Python mapping file%c", mapname, 0); + PyErr_SetString(PyExc_IOError, msg); return NULL; } |