How to propagate an exception ?
Stefan Schwarzer
s.schwarzer at ndh.net
Sat May 18 08:57:09 EDT 2002
Hello Shagshag
Shagshag wrote:
> How do you propagate an exception ? Is there a way to raise the
> previous exception raised after doing something ?
>
> Here what i would like to do :
>
> try:
> some_parsing_with_minidom(from_a_line)
> except SAXParseException: # (1)
> # there are trouble in my file such as & instead of &
> # and other things which prevent correct parsing but
> # i don't know where and what cause my trouble
> print index_of_line, line
> raise SAXParseException #<- should be the one i intercept in (1)
Simply use raise:
try:
some_parsing_with_minidom(from_a_line)
except SAXParseException: # (1)
# there are trouble in my file such as & instead of &
# and other things which prevent correct parsing but
# i don't know where and what cause my trouble
print index_of_line, line
raise #<- should be the one i intercept in (1) <- it is :-)
Stefan
More information about the Python-list
mailing list