[Tutor] Exceptions: Logging TB and local variables?

Allen Fowler allen.fowler at yahoo.com
Wed Oct 10 06:15:25 CEST 2007


Hi, 
 My code looks like this: 
 
for item in bigset: 
   self.__sub1(item) 
   self.__sub2(item) 
   self.__sub3(item) 
 
# the subX functions, in turn, use various 3rd party modules. 
 
Now, I would like to do this: 
 
for item in bigset: 
   try: 
     self.__sub1(item) 
     self.__sub2(item) 
     self.__sub3(item) 
   except StandardError: 
     # Log error and continue to next item in set. 
     log_error_to_file() 
 
In the error log, I would like to record a stacktrace and various local variables that existed in subX at the time the Exception was thrown... (even though the actual exception may have been thrown from deep inside some 3rd party module that subX called) 
 
How should I do this? 
 
Am I barking up the right tree?

Thank you, 
 Allen 
       
---------------------------------
Need a vacation? Get great deals to amazing places on Yahoo! Travel. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071009/a8030b0e/attachment.htm 


More information about the Tutor mailing list