add some nicer error handling

workspace
Brendan Howell 5 years ago
parent 0b503594e4
commit a918438b62

@ -81,6 +81,10 @@ class MailRoom(Bureau):
self.imapserv = imapclient.IMAPClient(self.host, use_uid=True, ssl=self.imap_ssl) self.imapserv = imapclient.IMAPClient(self.host, use_uid=True, ssl=self.imap_ssl)
self.imapserv.login(self.login, self.password) self.imapserv.login(self.login, self.password)
self.imapserv.select_folder("INBOX") 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): def _make_msg_object(self, imap_id, resp_obj):
""" """

@ -147,8 +147,13 @@ class Publications(Bureau):
try: try:
resp = requests.get(url, timeout=20.0, headers=headers) resp = requests.get(url, timeout=20.0, headers=headers)
except requests.ReadTimeout: except requests.ReadTimeout:
self.log.warning("Timeout reading RSS feed %s", url) self.log.warning("Timeout reading url %s", url)
return # TODO: do we need to spit out an error? 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 # re-render with readability
doc = readability.Document(resp.text, doc = readability.Document(resp.text,

Loading…
Cancel
Save