[PATCH 1/2] folder: IMAP: give better trace of errors while fetching

Nicolas Sebrecht nicolas.s-dev at laposte.net
Sun Jan 18 19:34:21 GMT 2015


Signed-off-by: Nicolas Sebrecht <nicolas.s-dev at laposte.net>
---
 offlineimap/folder/IMAP.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
index e0c0cc7..67748dd 100644
--- a/offlineimap/folder/IMAP.py
+++ b/offlineimap/folder/IMAP.py
@@ -224,11 +224,13 @@ class IMAPFolder(BaseFolder):
             res_type, response = imapobj.fetch("'%s'"%
                 msgsToFetch, '(FLAGS UID)')
             if res_type != 'OK':
-                raise OfflineImapError("FETCHING UIDs in folder [%s]%s failed. "
-                                       "Server responded '[%s] %s'"% (
-                            self.getrepository(), self,
-                            res_type, response),
-                        OfflineImapError.ERROR.FOLDER)
+                raise Exception("restype != 'OK'")
+        except Exception as e:
+            raise OfflineImapError("FETCHING UIDs in folder [%s]%s failed. "
+                "Server responded '[%s] %s' exception: '%s'"% (
+                self.getrepository(), self,
+                res_type, response, str(e)),
+                OfflineImapError.ERROR.FOLDER)
         finally:
             self.imapserver.releaseconnection(imapobj)
 
-- 
2.2.1





More information about the OfflineIMAP-project mailing list