aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/home/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'pydis_site/apps/home/views.py')
-rw-r--r--pydis_site/apps/home/views.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/pydis_site/apps/home/views.py b/pydis_site/apps/home/views.py
index 71f95293..0df84478 100644
--- a/pydis_site/apps/home/views.py
+++ b/pydis_site/apps/home/views.py
@@ -1,4 +1,5 @@
import logging
+from json.decoder import JSONDecodeError
import httpx
from django.core.handlers.wsgi import WSGIRequest
@@ -53,14 +54,24 @@ class HomeView(View):
repo_dict = {}
try:
# Fetch the data from the GitHub API
- api_data: list[dict] = httpx.get(
+ resp = httpx.get(
self.github_api,
headers=self.headers,
timeout=settings.TIMEOUT_PERIOD
- ).json()
+ )
+
+ resp.raise_for_status()
+
+ api_data: list[dict] = resp.json()
except httpx.TimeoutException:
log.error("Request to fetch GitHub repository metadata for timed out!")
return repo_dict
+ except httpx.HTTPStatusError as ex:
+ log.error(f"Received HTTP {ex.response.status_code} from GitHub repository metadata request!")
+ return repo_dict
+ except JSONDecodeError:
+ log.error("GitHub returned invalid JSON for repository metadata!")
+ return repo_dict
# Process the API data into our dict
for repo in api_data: