Catching exception information from ExpatError
python newbie
mesteve_b at hotmail.com
Thu Feb 26 08:03:00 EST 2004
Hey
Straightforward question:
I'm opening an xml file with minidom.
When I have a mismatch in the XML file, I simply want my python script to
not only stop gracefully, but also to call up UltraEdit with that xml file,
and highlighting the offending line (keep in mind UEdit can take command
line argument with the row and column)
When I let the exception be caught by default, I notice that I get:
xml.parsers.expat.ExpatError: mismatched tag: line 19, column 7
But when I catch the error with: except exp.ExpatError:
and then get the information from sys.exc_info(), it returns a tuple that
doesn't help:
class xml.parsers.expat.ExpatError at 0x00F7FF90>,
<xml.parsers.expat.ExpatError instance at 0x00FFD800>, <traceback object at
0x00FFD8C8>)
I want to somehow get the more useful: "line 19, column 7" and parse that
and call ultraedit with the 19 and the 7.
Can you suggest something, is it obvious?
thanks
Steve
More information about the Python-list
mailing list