- Better error handling, you can now send `raise_exception=True` to raise an `RequestError` when receiving a unsucessful response.
e.g
python
backwards compatible
c.Accounts.create(link="340eb1bc-1cd0-433c-9009-d4816313ff")
[{'field': 'link', 'message': "'340eb1bc-1cd0-433c-9009-d4816313ff' is not a valid UUID.", 'code': 'invalid'}]
force exception on errored response
c.Accounts.create(link="340eb1bc-1cd0-433c-9009-d4816313ff", raise_exception=True)
Traceback (most recent call last):
File "/home/menecio/projects/belvo-python/belvo/http.py", line 97, in post
r.raise_for_status()
File "/home/menecio/projects/belvo-python/.venv/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://localhost:8000/api/accounts/
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/menecio/projects/belvo-python/belvo/resources.py", line 119, in create
self.endpoint, data=data, raise_exception=raise_exception, **kwargs
File "/home/menecio/projects/belvo-python/belvo/http.py", line 99, in post
raise RequestError(r.status_code, r.json())
belvo.exceptions.RequestError: (400, [{'field': 'link', 'message': "'340eb1bc-1cd0-433c-9009-d4816313ff' is not a valid UUID.", 'code': 'invalid'}])