Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit c086a004 authored by Freezed's avatar Freezed
Browse files

:goal: Catch and print errors in API response

Related to #1
parent 8b4776b9
No related branches found
No related tags found
No related merge requests found
Pipeline #4279 passed
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
API utilities API utilities
""" """
from requests import HTTPError
from strava.api._helpers import client, url, json from strava.api._helpers import client, url, json
...@@ -11,7 +9,10 @@ def post_activity(xargs): ...@@ -11,7 +9,10 @@ def post_activity(xargs):
"""API call to create an activity""" """API call to create an activity"""
response = client.post(url=url("/activities"), data=xargs) response = client.post(url=url("/activities"), data=xargs)
try:
return json(response) if response.ok:
except HTTPError: result = json(response)
return response else:
result = response.json()
return result
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment