From 48f2df426727f4cc869eebf7ce14ff2a5c731089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Sat, 7 Aug 2021 20:33:06 +0200 Subject: [PATCH] Handle connection refused messages This patch handle the connection refused messages. One of these messages is related to returned zeros. --- offlineimap/imapserver.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index fb533a0..6acb331 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -677,6 +677,13 @@ class IMAPServer: "for repository '%s'. Remote does not answer." % (self.hostname, self.repos), OfflineImapError.ERROR.REPO, exc_info()[2]) + elif e.args and \ + e.args[0][:35] == 'IMAP4 protocol error: socket error:': + raise OfflineImapError( + "Could not connect to remote server '{}' " + "for repository '{}'. Connection Refused.".format( + self.hostname, self.repos), + OfflineImapError.ERROR.CRITICAL) else: # re-raise all other errors raise