summaryrefslogtreecommitdiff
path: root/odoo/http.py
diff options
context:
space:
mode:
authorfja-odoo <fja@odoo.com>2019-06-11 12:26:55 +0000
committerfja-odoo <fja@odoo.com>2019-06-28 08:53:53 +0000
commit0d1407a715901ea06e9a7211c0e3dbe09fadb785 (patch)
treed7d3a6cf49a358298b8caa2da8cd025be017c309 /odoo/http.py
parent90818fd083774988c331d741d34181a5af5ecd3a (diff)
[IMP] base, web, *: make KarmaError an except_orm
* = gamification, test_website, stock - KarmaError is now handled as a 400 exception. - test_website has been updated. - NO_POSTMORTEM is now clean it was referencing duplicates as most the exceptions inherit from except_orm. - serialize_exception from http.py has been moved to ir_http to take advantage of the odoo inheritance system. We can then extend ir_http serialize_exception method to add the KarmaError logic if and only if gamification is installed. Places where serialize_exception was previously used are updated. Part of https://github.com/odoo/odoo/pull/32132 task-1894820
Diffstat (limited to 'odoo/http.py')
-rw-r--r--odoo/http.py37
1 files changed, 6 insertions, 31 deletions
diff --git a/odoo/http.py b/odoo/http.py
index ab4512a6321..25200ebcecf 100644
--- a/odoo/http.py
+++ b/odoo/http.py
@@ -98,16 +98,16 @@ def replace_request_password(args):
args[2] = '*'
return tuple(args)
+
# don't trigger debugger for those exceptions, they carry user-facing warnings
# and indications, they're not necessarily indicative of anything being
# *broken*
-NO_POSTMORTEM = (odoo.osv.orm.except_orm,
- odoo.exceptions.AccessError,
- odoo.exceptions.ValidationError,
- odoo.exceptions.MissingError,
+NO_POSTMORTEM = (odoo.exceptions.except_orm,
odoo.exceptions.AccessDenied,
odoo.exceptions.Warning,
odoo.exceptions.RedirectWarning)
+
+
def dispatch_rpc(service_name, method, params):
""" Handle a RPC call.
@@ -316,7 +316,7 @@ class WebRequest(object):
"""Called within an except block to allow converting exceptions
to abitrary responses. Anything returned (except None) will
be used as response."""
- self._failed = exception # prevent tx commit
+ self._failed = exception # prevent tx commit
if not isinstance(exception, NO_POSTMORTEM) \
and not isinstance(exception, werkzeug.exceptions.HTTPException):
odoo.tools.debugger.post_mortem(
@@ -641,7 +641,7 @@ class JsonRequest(WebRequest):
error = {
'code': 200,
'message': "Odoo Server Error",
- 'data': serialize_exception(exception),
+ 'data': request.registry['ir.http'].serialize_exception(exception),
}
if isinstance(exception, werkzeug.exceptions.NotFound):
error['http_status'] = 404
@@ -691,31 +691,6 @@ class JsonRequest(WebRequest):
except Exception as e:
return self._handle_exception(e)
-def serialize_exception(e):
- tmp = {
- "name": type(e).__module__ + "." + type(e).__name__ if type(e).__module__ else type(e).__name__,
- "debug": traceback.format_exc(),
- "message": ustr(e),
- "arguments": e.args,
- "exception_type": "internal_error"
- }
- if isinstance(e, odoo.exceptions.UserError):
- tmp["exception_type"] = "user_error"
- elif isinstance(e, odoo.exceptions.Warning):
- tmp["exception_type"] = "warning"
- elif isinstance(e, odoo.exceptions.RedirectWarning):
- tmp["exception_type"] = "warning"
- elif isinstance(e, odoo.exceptions.AccessError):
- tmp["exception_type"] = "access_error"
- elif isinstance(e, odoo.exceptions.MissingError):
- tmp["exception_type"] = "missing_error"
- elif isinstance(e, odoo.exceptions.AccessDenied):
- tmp["exception_type"] = "access_denied"
- elif isinstance(e, odoo.exceptions.ValidationError):
- tmp["exception_type"] = "validation_error"
- elif isinstance(e, odoo.exceptions.except_orm):
- tmp["exception_type"] = "except_orm"
- return tmp
class HttpRequest(WebRequest):
""" Handler for the ``http`` request type.