From 611ee897482d029482baa421ca276cdcd0e79f48 Mon Sep 17 00:00:00 2001 From: Freezed <2160318-free_zed@users.noreply.gitlab.com> Date: Thu, 24 Mar 2022 00:40:32 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20Catch=20and=20print=20errors=20i?= =?UTF-8?q?n=20API=20response=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cli/api.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cli/api.py b/cli/api.py index 22b11f1..036123e 100644 --- a/cli/api.py +++ b/cli/api.py @@ -2,8 +2,6 @@ API utilities """ -from requests import HTTPError - from strava.api._helpers import client, url, json @@ -11,7 +9,10 @@ def post_activity(xargs): """API call to create an activity""" response = client.post(url=url("/activities"), data=xargs) - try: - return json(response) - except HTTPError: - return response + + if response.ok: + result = json(response) + else: + result = response.json() + + return result -- GitLab