From ca88b71f481d159fdd4833e39f520b3e87c7e092 Mon Sep 17 00:00:00 2001 From: Sandro Bonazzola Date: Wed, 20 Sep 2023 17:36:31 +0200 Subject: [PATCH] Handle connection error fetching gitlab user Handle more gracefully connection issues while looking up for a user on GitLab. Previously only a traceback was generated, now an application error is printed on the screen. Observed during https://gitlab.gnome.org/ outage Signed-off-by: Sandro Bonazzola --- did/plugins/gitlab.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/did/plugins/gitlab.py b/did/plugins/gitlab.py index cfd01448..939ee322 100644 --- a/did/plugins/gitlab.py +++ b/did/plugins/gitlab.py @@ -94,7 +94,12 @@ def _get_gitlab_api_list( def get_user(self, username): query = 'users?username={0}'.format(username) - result = self._get_gitlab_api_json(query) + try: + result = self._get_gitlab_api_json(query) + except requests.exceptions.JSONDecodeError as jde: + raise ReportError( + f"Unable to query user '{username}' on {self.url}." + ) from jde try: return result[0] except IndexError: