diff --git a/blueprints/projects.py b/blueprints/projects.py index 7c792b4..a7ce9e3 100644 --- a/blueprints/projects.py +++ b/blueprints/projects.py @@ -31,12 +31,15 @@ class Blueprint(flask.Blueprint): self._apiKey = os.getenv('GITEA_TOKEN') self.giteaUID = None - r = requests.get(self.constructURL('/api/v1/user'), timeout=5) + try: + r = requests.get(self.constructURL('/api/v1/user'), timeout=5) - if r.ok: - self.giteaUID = r.json().get('id') - else: - log.error('Cannot get Gitea user ID. This blueprint will not work.') + if r.ok: + self.giteaUID = r.json().get('id') + else: + log.error('Cannot get Gitea user ID. This blueprint will not work.') + except requests.exceptions.ConnectionError: + log.error('Failed to connect to Gitea server. This blueprint will not work.') super().__init__(*args, **kwargs)