Handle errors more gently when API requests fails

This commit is contained in:
Théophile Diot 2023-05-05 10:22:38 -04:00
parent d4934cfee5
commit 63ce1afcdd
No known key found for this signature in database
GPG Key ID: E752C80DB72BB014
1 changed files with 9 additions and 7 deletions

View File

@ -138,14 +138,16 @@ class ApiCaller:
f"Successfully sent API request to {api.get_endpoint()}{url}",
)
if response:
instance = api.get_endpoint().replace("http://", "").split(":")[0]
if isinstance(resp, dict):
responses[instance] = resp
else:
responses[instance] = resp.json()
if response:
instance = (
api.get_endpoint().replace("http://", "").split(":")[0]
)
if isinstance(resp, dict):
responses[instance] = resp
else:
responses[instance] = resp.json()
if response:
if response and responses:
return ret, responses
return ret