Use more appropriate HTTP status for Tryton exceptions
issue8929 review252781002
This commit is contained in:
1 parent
4920c59650
commit
03b07a60e9
2 files changed
+34
-6
No files matched your search
@@ -7,10 +7,14 @@ import base64
|
||||
|
||||
from werkzeug.wrappers import Response
|
||||
from werkzeug.utils import cached_property
|
||||
from werkzeug.exceptions import BadRequest, InternalServerError
|
||||
from werkzeug.exceptions import (
|
||||
BadRequest, InternalServerError, Conflict, Forbidden, Locked,
|
||||
TooManyRequests)
|
||||
|
||||
from trytond.protocols.wrappers import Request
|
||||
from trytond.exceptions import TrytonException
|
||||
from trytond.exceptions import (
|
||||
TrytonException, UserWarning, LoginException, ConcurrencyException,
|
||||
RateLimitException, MissingDependenciesException)
|
||||
|
||||
|
||||
class JSONDecoder(object):
|
||||
@@ -153,7 +157,17 @@ class JSONProtocol:
|
||||
else:
|
||||
response['result'] = data
|
||||
else:
|
||||
if isinstance(data, TrytonException):
|
||||
if isinstance(data, UserWarning):
|
||||
return Conflict(data)
|
||||
elif isinstance(data, LoginException):
|
||||
return Forbidden(data)
|
||||
elif isinstance(data, ConcurrencyException):
|
||||
return Locked(data)
|
||||
elif isinstance(data, RateLimitException):
|
||||
return TooManyRequests(data)
|
||||
elif isinstance(data, MissingDependenciesException):
|
||||
return InternalServerError(data)
|
||||
elif isinstance(data, TrytonException):
|
||||
return BadRequest(data)
|
||||
elif isinstance(data, Exception):
|
||||
return InternalServerError(data)
|
||||
|
||||
@@ -9,10 +9,14 @@ from decimal import Decimal
|
||||
|
||||
from werkzeug.wrappers import Response
|
||||
from werkzeug.utils import cached_property
|
||||
from werkzeug.exceptions import BadRequest, InternalServerError
|
||||
from werkzeug.exceptions import (
|
||||
BadRequest, InternalServerError, Conflict, Forbidden, Locked,
|
||||
TooManyRequests)
|
||||
|
||||
from trytond.protocols.wrappers import Request
|
||||
from trytond.exceptions import TrytonException
|
||||
from trytond.exceptions import (
|
||||
TrytonException, UserWarning, LoginException, ConcurrencyException,
|
||||
RateLimitException, MissingDependenciesException)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -153,7 +157,17 @@ class XMLProtocol:
|
||||
data, methodresponse=True, allow_none=True),
|
||||
content_type='text/xml')
|
||||
else:
|
||||
if isinstance(data, TrytonException):
|
||||
if isinstance(data, UserWarning):
|
||||
return Conflict(data)
|
||||
elif isinstance(data, LoginException):
|
||||
return Forbidden(data)
|
||||
elif isinstance(data, ConcurrencyException):
|
||||
return Locked(data)
|
||||
elif isinstance(data, RateLimitException):
|
||||
return TooManyRequests(data)
|
||||
elif isinstance(data, MissingDependenciesException):
|
||||
return InternalServerError(data)
|
||||
elif isinstance(data, TrytonException):
|
||||
return BadRequest(data)
|
||||
elif isinstance(data, Exception):
|
||||
return InternalServerError(data)
|
||||
|
||||
Reference in new issue
Block a user