[PATCH] improve message "error 111" if connection failed

Nicolas Sebrecht nicolas.s-dev at laposte.net
Tue May 24 22:58:43 BST 2011


Raise OfflineImapError with severity REPO explaining that the connection failed.
Before, no valuable information was given to the user.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev at laposte.net>
---

THIS IS UNTESTED STUFF.
Please, check is fixes your address.

 offlineimap/imaplibutil.py |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/offlineimap/imaplibutil.py b/offlineimap/imaplibutil.py
index 6c6142c..80faa06 100644
--- a/offlineimap/imaplibutil.py
+++ b/offlineimap/imaplibutil.py
@@ -172,8 +172,9 @@ class WrappedIMAP4_SSL(UsefulIMAPMixIn, IMAP4_SSL):
             else:
                 self.sock.close()
         if last_error != 0:
-            # FIXME
-            raise socket.error(last_error)
+            raise OfflineImapError(
+                "connection to a remote failed with error %s" % socket.error(last_error),
+                OfflineImapError.ERROR.REPO)
 
         # Allow sending of keep-alive message seems to prevent some servers
         # from closing SSL on us leading to deadlocks
@@ -276,8 +277,9 @@ class WrappedIMAP4(UsefulIMAPMixIn, IMAP4):
             else:
                 self.sock.close()
         if last_error != 0:
-            # FIXME
-            raise socket.error(last_error)
+            raise OfflineImapError(
+                "connection to a remote failed with error %s" % socket.error(last_error),
+                OfflineImapError.ERROR.REPO)
         self.file = self.sock.makefile('rb')
 
         # imaplib2 uses this to poll()
-- 
1.7.5.1.354.g761178





More information about the OfflineIMAP-project mailing list