try/finally exceptions dying
stephen.y4ng at gmail.com
stephen.y4ng at gmail.com
Tue Aug 14 15:09:51 EDT 2007
Hello all,
In order to churn through a whole bunch of data sets (some good, some
bad..) and get all the errors at the end, (the data will be updated to
make it all good later on) I implemented a try/finally block with a
higher level handler to catch errors before they propagate to the
default handler and crash the program. Something like this:
def doStuff(args):
if(args says we should keep going):
try:
stuff
finally:
update args
doStuff(updated args)
def runWithErrorHandling():
try:
doStuff(args)
except (exception1, exception2), data:
<handle exception here...>
append exception data to a list of errors
runWithErrorHandling()
unfortunately, this churns through all the data and I only get the
last exception that occurred in the error list, not all of them, as I
expected. What is going on? I thought finally always propagated the
exception all the way up the stack until it was handled.
Any thoughts are appreciated.
Stephen
More information about the Python-list
mailing list