Return bad request for Tryton exception instead of internal error

Those exceptions are expected behavior so it is the fault of the client, not
the server.

issue8768
review276221002
This commit is contained in:
Cédric Krier
2019-11-17 17:36:07 +01:00
parent f4a7c8d395
commit 922c420fae
3 changed files with 7 additions and 2 deletions
+1
View File
@@ -1,3 +1,4 @@
* Return 400 instead of 500 for Tryton exception
* Fill the reverse field in the One2Many setter
* Drop support for skiptest attribute on xml files
* Remove implicit field names in ModelStorage.search_read
+3 -1
View File
@@ -153,7 +153,9 @@ class JSONProtocol:
else:
response['result'] = data
else:
if isinstance(data, Exception):
if isinstance(data, TrytonException):
return BadRequest(data)
elif isinstance(data, Exception):
return InternalServerError(data)
response = data
return Response(json.dumps(
+3 -1
View File
@@ -153,6 +153,8 @@ class XMLProtocol:
data, methodresponse=True, allow_none=True),
content_type='text/xml')
else:
if isinstance(data, Exception):
if isinstance(data, TrytonException):
return BadRequest(data)
elif isinstance(data, Exception):
return InternalServerError(data)
return Response(data)