[PATCH] Better trace information when an exception is caught.

Edward Z. Yang ezyang at MIT.EDU
Thu Jan 27 16:50:32 GMT 2011


Signed-off-by: Edward Z. Yang <ezyang at mit.edu>
---
 offlineimap/accounts.py        |    5 +++--
 offlineimap/folder/Base.py     |    9 +++++----
 offlineimap/repository/Base.py |    3 ++-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py
index 667d2b2..93c6593 100644
--- a/offlineimap/accounts.py
+++ b/offlineimap/accounts.py
@@ -24,6 +24,7 @@ from threading import Event, Lock
 import os
 from Queue import Queue, Empty
 import sys
+import traceback
 
 class SigListener(Queue):
     def __init__(self):
@@ -189,7 +190,7 @@ class AccountSynchronizationMixin:
                     self.sync(siglistener)
                 except:
                     self.ui.warn("Error occured attempting to sync account " + self.name \
-                                 + ": " + str(sys.exc_info()[1]))
+                                 + ": " + traceback.format_exc())
             finally:
                 self.ui.acctdone(self.name)
 
@@ -203,7 +204,7 @@ class AccountSynchronizationMixin:
                     self.sync(siglistener)
                 except:
                     self.ui.warn("Error occured attempting to sync account " + self.name \
-                                 + ": " + str(sys.exc_info()[1]))
+                                 + ": " + traceback.format_exc())
             finally:
                 looping = self.sleeper(siglistener) != 2
                 self.ui.acctdone(self.name)
diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
index 0f38bc3..88bba8b 100644
--- a/offlineimap/folder/Base.py
+++ b/offlineimap/folder/Base.py
@@ -22,6 +22,7 @@ from offlineimap.threadutil import InstanceLimitedThread
 from offlineimap.ui import UIBase
 import os.path, re
 import sys
+import traceback
 
 class BaseFolder:
     def __init__(self):
@@ -290,7 +291,7 @@ class BaseFolder:
                     uid = newuid
         except:
             UIBase.getglobalui().warn("ERROR attempting to copy message " + str(uid) \
-                 + " for account " + self.getaccountname() + ":" + str(sys.exc_info()[1]))
+                 + " for account " + self.getaccountname() + ":" + traceback.format_exc())
         
 
     def syncmessagesto_copy(self, dest, applyto):
@@ -395,7 +396,7 @@ class BaseFolder:
             self.syncmessagesto_neguid(dest, applyto)
         except:
             UIBase.getglobalui().warn("ERROR attempting to handle negative uids " \
-                + "for account " + self.getaccountname() + ":" + str(sys.exc_info()[1]))
+                + "for account " + self.getaccountname() + ":" + traceback.format_exc())
 
         #all threads launched here are in try / except clauses when they copy anyway...
         self.syncmessagesto_copy(dest, applyto)
@@ -404,7 +405,7 @@ class BaseFolder:
             self.syncmessagesto_delete(dest, applyto)
         except:
             UIBase.getglobalui().warn("ERROR attempting to delete messages " \
-                + "for account " + self.getaccountname() + ":" + str(sys.exc_info()[1]))
+                + "for account " + self.getaccountname() + ":" + traceback.format_exc())
 
         # Now, the message lists should be identical wrt the uids present.
         # (except for potential negative uids that couldn't be placed
@@ -414,6 +415,6 @@ class BaseFolder:
             self.syncmessagesto_flags(dest, applyto)
         except:
             UIBase.getglobalui().warn("ERROR attempting to sync flags " \
-                + "for account " + self.getaccountname() + ":" + str(sys.exc_info()[1]))
+                + "for account " + self.getaccountname() + ":" + traceback.format_exc())
         
             
diff --git a/offlineimap/repository/Base.py b/offlineimap/repository/Base.py
index a9d98f1..a4b9e66 100644
--- a/offlineimap/repository/Base.py
+++ b/offlineimap/repository/Base.py
@@ -20,6 +20,7 @@ from offlineimap import CustomConfig
 from offlineimap.ui import UIBase
 import os.path
 import sys
+import traceback
 
 def LoadRepository(name, account, reqtype):
     from offlineimap.repository.Gmail import GmailRepository
@@ -165,7 +166,7 @@ class BaseRepository(CustomConfig.ConfigHelperMixin):
                         copyfolder.makefolder(key.replace(dest.getsep(), copyfolder.getsep()))
                 except:
                     UIBase.getglobalui().warn("ERROR Attempting to make folder " \
-                        + key + ":"  +str(sys.exc_info()[1]))
+                        + key + ":"  +traceback.format_exc())
                 
 
         #
-- 
1.7.0.4





More information about the OfflineIMAP-project mailing list