saving an exception
steve at holdenweb.com
Tue Oct 3 08:46:28 CEST 2006
> i would like to save an exception and reraise it at a later time.
> something similar to this:
> exception = None
> def foo():
> except Exception, e:
> exception = e
> if exception: raise exception
> i have a need to do this because in my example foo is a callback from c code
> which was originally called from python and i can't modify the c code.
> with the above code, i'm able to successfully raise the exception, but the
> line number of the exception is at the place of the explicit raise instead
> of the where the exception originally occurred. is there anyway to fix
You can capture the trace at the time the original exception is raised,
if that would help? I think the traceback module lets you do that.
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list