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

Tom Schutter tschutter at corelogic.com
Tue May 24 23:46:16 UTC 2011


Tested patch, looks good.

On Tue 2011-05-24 16:58, Nicolas Sebrecht wrote:
> 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
> 
> 

-- 
Tom Schutter
CoreLogic Spatial Solutions
Office: 303-440-7272 x6822 or 512-977-6822
Cell: 303-349-4374



More information about the OfflineIMAP-project mailing list