Prepending to traceback
Thomas Guettler
guettli at thomas-guettler.de
Wed Feb 2 10:35:17 EST 2005
Am Wed, 02 Feb 2005 13:55:24 +0100 schrieb Stefan Behnel:
> Hi!
>
> I'm writing a parser using pyparsing and I would like to augment the
> ParserException tracebacks with information about the actual error line *in
> the parsed text*. Pyparsing provides me with everything I need (parsed line
> and column), but is there a way to push that information on the traceback?
Hi,
have a look at the source of ParseException. I guess there
is attribute which holds the string. If the attribute is "msg",
you could do it like this:
try:
....
except ParseException, e:
e.msg="Textbefore %s" % e.msg
raise e
(code is not tested)
Thomas
--
Thomas Güttler, http://www.thomas-guettler.de/
More information about the Python-list
mailing list