# HG changeset patch # User cmlenz # Date 1123888016 0 # Node ID 1a1a294ce10e3cfde4f7fd5bcb7dbbf6b11b60ee # Parent 07505cab4ba6d24555e73409fac5be7262b00766 Catch XML parse errors in the {{{}}} command. diff --git a/bitten/build/pythontools.py b/bitten/build/pythontools.py --- 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) diff --git a/bitten/util/xmlio.py b/bitten/util/xmlio.py --- 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):