Skip to content
This repository was archived by the owner on Feb 19, 2021. It is now read-only.

Commit 2cd077d

Browse files
authored
Merge pull request #475 from syntonym/master
Catch IMAP connection errors
2 parents 0256dcb + 5c1edf7 commit 2cd077d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/documents/mail.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,11 @@ def _get_messages(self):
216216
return r
217217

218218
def _connect(self):
219-
self._connection = imaplib.IMAP4_SSL(self._host, self._port)
219+
try:
220+
self._connection = imaplib.IMAP4_SSL(self._host, self._port)
221+
except OSError as e:
222+
msg = "Problem connecting to {}: {}".format(self._host, e.strerror)
223+
raise MailFetcherError(msg)
220224

221225
def _login(self):
222226

0 commit comments

Comments
 (0)