Re-throwing an exception without loosing the stack trace
Skip Montanaro
skip at pobox.com
Tue Feb 12 17:36:06 EST 2002
Clark> How do I catch and then re-throw an exception without loosing the
Clark> information about the stack trace? I've looked around alot and
Clark> don't see the "obvious" answer.
Assuming you mean something like
try:
bunch
of
stuff
that
might
barf
except:
clean
up
database
turds
then
reraise
when you are finished cleaning up you can just execute the raise statement
with no arguments. Better might be this:
try:
bunch
of
stuff
that
might
barf
finally:
clean
up
database
turds
That way the database stuff gets cleaned up no matter what happened.
--
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)
More information about the Python-list
mailing list