Better handle healthcheck errors

This commit is contained in:
Jake Howard 2023-08-19 13:19:42 +01:00
parent e870f4b162
commit 8c7f6b7f69
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 10 additions and 4 deletions

View file

@ -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")

View file

@ -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"