[FIX] iap_odoo: fix error general error raise

Errors that are not whitelisted are not managed correctly due to the jsonrpc behaviour in Odoo.

When we make a post in json using iap.jsonrpc function, it contacts iap.odoo.com.
However, if this url does not respond, it falls back to the 'typo' page and the answer to the call
has a '200' status code but with an 'error' key in its response.

Currently, we manage the errors via whitelisting, which hides this kind of errors.
We opted to raise this error (odoo server side) as a UserError and to add UserError to the whitelist.
This commit is contained in:
Rémi Rahir
2017-10-18 17:08:21 +02:00
parent 542b8fd550
commit 47b8887ff5
+3 -1
View File
@@ -57,8 +57,10 @@ def jsonrpc(url, method='call', params=None):
e_class = InsufficientCreditError
elif name == 'AccessError':
e_class = exceptions.AccessError
else:
elif name == 'UserError':
e_class = exceptions.UserError
else:
raise requests.exceptions.ConnectionError()
e = e_class(message)
e.data = response['error']['data']
raise e