From 8c7f6b7f690efa1b4c2cc2c67f1531eed8ec00e1 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 19 Aug 2023 13:19:42 +0100 Subject: [PATCH] Better handle healthcheck errors --- website/contrib/code_block/healthchecks.py | 5 ++++- website/spotify/healthchecks.py | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/website/contrib/code_block/healthchecks.py b/website/contrib/code_block/healthchecks.py index 55608f3..d690e2a 100644 --- a/website/contrib/code_block/healthchecks.py +++ b/website/contrib/code_block/healthchecks.py @@ -5,7 +5,10 @@ from .utils import _get_linguist_colours class GitHubLinguistHealthCheckBackend(BaseHealthCheckBackend): def check_status(self) -> None: - colours = _get_linguist_colours() + try: + colours = _get_linguist_colours() + except Exception as e: + self.add_error(str(e)) if colours is None: self.add_error("No colours provided") diff --git a/website/spotify/healthchecks.py b/website/spotify/healthchecks.py index 937c928..0f72319 100644 --- a/website/spotify/healthchecks.py +++ b/website/spotify/healthchecks.py @@ -5,9 +5,12 @@ from health_check.backends import BaseHealthCheckBackend class SpotifyHealthCheckBackend(BaseHealthCheckBackend): def check_status(self) -> None: - requests.get( - f"https://{settings.SPOTIFY_PROXY_HOST}/.health/" - ).raise_for_status() + try: + requests.get( + f"https://{settings.SPOTIFY_PROXY_HOST}/.health/" + ).raise_for_status() + except Exception as e: + self.add_error(str(e)) def identifier(self) -> str: return "Spotify Proxy"