improve message "error 111" if connection failed
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@laposte.net>
This commit is contained in:
parent
da36c5c1e7
commit
fc6c12d96c
@ -172,8 +172,8 @@ class WrappedIMAP4_SSL(UsefulIMAPMixIn, IMAP4_SSL):
|
|||||||
else:
|
else:
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
if last_error != 0:
|
if last_error != 0:
|
||||||
# FIXME
|
raise Exception("can't open socket; error: %s"\
|
||||||
raise socket.error(last_error)
|
% socket.error(last_error))
|
||||||
|
|
||||||
# Allow sending of keep-alive message seems to prevent some servers
|
# Allow sending of keep-alive message seems to prevent some servers
|
||||||
# from closing SSL on us leading to deadlocks
|
# from closing SSL on us leading to deadlocks
|
||||||
@ -276,8 +276,8 @@ class WrappedIMAP4(UsefulIMAPMixIn, IMAP4):
|
|||||||
else:
|
else:
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
if last_error != 0:
|
if last_error != 0:
|
||||||
# FIXME
|
raise Exception("can't open socket; error: %s"\
|
||||||
raise socket.error(last_error)
|
% socket.error(last_error))
|
||||||
self.file = self.sock.makefile('rb')
|
self.file = self.sock.makefile('rb')
|
||||||
|
|
||||||
# imaplib2 uses this to poll()
|
# imaplib2 uses this to poll()
|
||||||
|
@ -289,6 +289,13 @@ class IMAPServer:
|
|||||||
"ver name correctly and that you are online."\
|
"ver name correctly and that you are online."\
|
||||||
% (self.hostname, self.reposname)
|
% (self.hostname, self.reposname)
|
||||||
raise OfflineImapError(reason, severity)
|
raise OfflineImapError(reason, severity)
|
||||||
|
# Could not acquire connection to the remote;
|
||||||
|
# socket.error(last_error) raised
|
||||||
|
if str(e)[:24] == "can't open socket; error":
|
||||||
|
raise OfflineImapError("Could not connect to remote server '%s' "\
|
||||||
|
"for repository '%s'. Remote does not answer."
|
||||||
|
% (self.hostname, self.reposname),
|
||||||
|
OfflineImapError.ERROR.REPO)
|
||||||
else:
|
else:
|
||||||
# re-raise all other errors
|
# re-raise all other errors
|
||||||
raise
|
raise
|
||||||
|
Loading…
x
Reference in New Issue
Block a user