From 11b133f14dc4fadd604a7d52f2c0db34da88ad92 Mon Sep 17 00:00:00 2001 From: b3yond Date: Sat, 2 Feb 2019 22:02:56 +0100 Subject: [PATCH] don't log Mastodon 502 errors. --- active_bots/mastodonbot.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/active_bots/mastodonbot.py b/active_bots/mastodonbot.py index 0189dca..6e7ee0d 100755 --- a/active_bots/mastodonbot.py +++ b/active_bots/mastodonbot.py @@ -2,7 +2,7 @@ from bot import Bot import logging -from mastodon import Mastodon +from mastodon import Mastodon, MastodonAPIError import re from report import Report @@ -25,7 +25,13 @@ class MastodonBot(Bot): return mentions try: notifications = m.notifications() - except Exception: + except MastodonAPIError: + # Not tested yet, as we don't have a dysfunctional Mastodon instance. + for arg in MastodonAPIError.args: + if arg == 502: + # Don't log 502 errors + return mentions + logger.error("Unknown Mastodon API Error.", exc_info=True) return mentions for status in notifications: