changeset 134:1a1a294ce10e

Catch XML parse errors in the {{{<python:unittest>}}} command.
author cmlenz
date Fri, 12 Aug 2005 23:06:56 +0000
parents 07505cab4ba6
children d2b833187429
files bitten/build/pythontools.py bitten/util/xmlio.py
diffstat 2 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/build/pythontools.py
+++ b/bitten/build/pythontools.py
@@ -126,7 +126,7 @@
         finally:
             summary_file.close()
     except IOError, e:
-        log.warning('Error opening unittest results file (%s)', e)
+        log.warning('Error opening coverage summary file (%s)', e)
 
 
 def unittest(ctxt, file=None):
@@ -149,3 +149,5 @@
             fd.close()
     except IOError, e:
         log.warning('Error opening unittest results file (%s)', e)
+    except xmlio.ParseError, e:
+        log.warning('Error parsing unittest results file (%s)', e)
--- a/bitten/util/xmlio.py
+++ b/bitten/util/xmlio.py
@@ -176,13 +176,21 @@
         parent_.append(self)
 
 
+class ParseError(Exception):
+    """Exception thrown when there's an error parsing an XML document."""
+
+
 def parse(text):
     from xml.dom import minidom
-    if isinstance(text, (str, unicode)):
-        dom = minidom.parseString(text)
-    else:
-        dom = minidom.parse(text)
-    return ParsedElement(dom.documentElement)
+    from xml.parsers import expat
+    try:
+        if isinstance(text, (str, unicode)):
+            dom = minidom.parseString(text)
+        else:
+            dom = minidom.parse(text)
+        return ParsedElement(dom.documentElement)
+    except expat.error, e:
+        raise ParseError, e
 
 
 class ParsedElement(object):
Copyright (C) 2012-2017 Edgewall Software