From a918438b62f533174f0e8bd5800b3189aaac921e Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Fri, 3 Apr 2020 11:01:58 +0200 Subject: [PATCH] add some nicer error handling --- screenless/bureau/mailroom/mailroom.py | 4 ++++ screenless/bureau/publications/publications.py | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/screenless/bureau/mailroom/mailroom.py b/screenless/bureau/mailroom/mailroom.py index b105d58..4e24048 100644 --- a/screenless/bureau/mailroom/mailroom.py +++ b/screenless/bureau/mailroom/mailroom.py @@ -81,6 +81,10 @@ class MailRoom(Bureau): self.imapserv = imapclient.IMAPClient(self.host, use_uid=True, ssl=self.imap_ssl) self.imapserv.login(self.login, self.password) self.imapserv.select_folder("INBOX") + except self.imapserv.Error as err: + self.log.debug("IMAP connection error: %err", err) + self.smprint("IMAP connection error: " + str(err)) + def _make_msg_object(self, imap_id, resp_obj): """ diff --git a/screenless/bureau/publications/publications.py b/screenless/bureau/publications/publications.py index 85395fd..890a74e 100644 --- a/screenless/bureau/publications/publications.py +++ b/screenless/bureau/publications/publications.py @@ -147,8 +147,13 @@ class Publications(Bureau): try: resp = requests.get(url, timeout=20.0, headers=headers) except requests.ReadTimeout: - self.log.warning("Timeout reading RSS feed %s", url) - return # TODO: do we need to spit out an error? + self.log.warning("Timeout reading url %s", url) + self.print_small("Error: timed out reading " + url) + return + except requests.ConnectionError as e: + self.log.warning("Error reading url %s", url) + self.print_small("Error: connect error on " + url) + return # re-render with readability doc = readability.Document(resp.text,