[SciPy-user] try/finally exceptions dying

Stephen Yang scyang@nist....
Tue Aug 14 12:06:13 CDT 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
 
   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070814/62816926/attachment.html 


More information about the SciPy-user mailing list