This repository was archived by the owner on Jul 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
This repository was archived by the owner on Jul 3, 2023. It is now read-only.
More descriptive error messages #26
Copy link
Copy link
Open
Description
Description:
When providing an incorect request body, the error messge is not descriptive enough.
Example:
from typeform import Typeform
r = Typeform("XXXXXXXX").forms.create(data={
"title": "Incorrect form payload",
"type": "quiz",
"theme": https://api.typeform.com/themes/GKFi5U"
})
Raises the following exception:
...
File ~/Projects/coef/typeform-python-sdk/typeform/client.py:41, in Client.__validator(self, result)
39 if type(body) is dict and body.get('code', None) is not None:
40 print(body)
---> 41 raise Exception(body.get('description'))
42 elif result.status_code >= 400:
43 raise Exception(result.reason)
Exception: The payload is invalid.
If you are to intercept the HTTP response, you will receive a much more verbose error message:
{
"code": "VALIDATION_ERROR",
"description": "The payload is invalid.",
"details": [
{
"code": "WRONG_TYPE",
"description": "should be object,null",
"field": "/theme",
"in": "body"
}
]
}
Motivation for or Use Case:
I'd like to handle errors better and understand where the issue is
Related Issues - has a similar issue been reported before?:
#16 Invalid payload error when creating a new Typeform
Environment Configuration:
Latest revision at: ccfe1ec
Suggest a Fix:
# in typeform/client.py L39:
if type(body) is dict and body.get('code', None) is not None:
print(f"Error code: {body.get('code')}")
print(f"Error details: {body.get('details')}")
raise Exception(body.get('description'))
Metadata
Metadata
Assignees
Labels
No labels