Skip to content

Commit 8dc9aea

Browse files
authored
Fix when there is a valid response but there is no description in it. It will display the whole response.
1 parent 782ff23 commit 8dc9aea

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

typeform/client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ def _parse(self, response):
4242
if not response.ok:
4343
try:
4444
data = response.json()
45-
if 'description' in data and 'code' in data:
45+
if 'description' in data:
4646
message = data['description']
47+
else:
48+
message = data
49+
if 'code' in data:
4750
code = data['code']
51+
else:
52+
code = "There was no code in the response."
4853
except:
4954
code = response.status_code
5055
message = ""
@@ -174,4 +179,4 @@ def delete_webhook(self, tag_webhook, uid):
174179
if self.access_token is not None:
175180
return self._delete(endpoint='forms/{1}/webhooks/{0}'.format(tag_webhook, uid)).ok
176181
else:
177-
raise exception.TokenRequired("You need an access token for this method")
182+
raise exception.TokenRequired("You need an access token for this method")

0 commit comments

Comments
 (0)