diff options
| author | Julien Castiaux <juc@odoo.com> | 2020-02-19 13:34:27 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-04-08 08:41:17 +0000 |
| commit | ab4000fb3cf8fa54ba714ceceec391b78d73755e (patch) | |
| tree | b28702ae04a1ce3628f9c6a3ffbd4a9c95324d4d /addons/web/static/src | |
| parent | 640e63e371a511c0d6786154408c6f5704077947 (diff) | |
[REF] base: Remove deprecated exceptions and osv
TL;DR: remember `osv` and `except_orm` ? You can forget about them.
* Deprecated `except_orm` dropped.
* `UserError` elevated as super type of all user-related
errors.
* Unused `DeferredException` dropped.
* Unused `QWebException` dropped (real one is in `qweb.py`).
* `MailDeliveryException` made a python exception.
* `name` legacy exception attribute made an alias of the python standard
`args[0]` attribute and deprecated.
* `value` legacy exception attribute dropped.
* `exception_type` RPC error response key dropped.
* Deprecated `osv` module dropped.
* `--osv-memory-age-limit` cli option made an alias of
`--transient-age-limit` and deprecated.
The `odoo.exceptions.Warning` have long been a deprecated alias to
`UserError`. It is going to be removed in a future version but first we
explicitly deprecate it with a warning.
The `odoo.exceptions.DeferredException` was a very old internal
exception, it has been removed without deprecation notice as it is never
raised.
The `odoo.exceptions.except_orm` has been a deprecated exception type
with deprecation warning for 5 years, it has been removed in favor of
UserError which becomes the super class of all user-related errors.
The `odoo.base.models.ir_mail_server.MailDeliveryException` was
inheriting `except_orm`. As it is not related to a user error but is
more of a problem an admin much take care of, the exception has been
made a Python error.
The `exception_type` JSON key in RPC error responses was holding an
hardcoded value derived from the exception type. Its usage has been
dropped in favor of the `name` JSON key that holds the precise exception
name. Again as it was hardly used in the source code (beside the crash
manager) it has been dropped without deprecation warning.
Since we are here trying to clean odoo custom exceptions, we are also
deprecating the `name` exception attribute in favor of the more standard
`args[0]` attribute.
The `name` (along with `value`) were two attributes used to raise
`except_orm` exceptions before the introduction of `UserError`,
`AccessError` and related exceptions. The `name` attribute, at the time,
was holding the exception type/title. Nowadays it contains the error
message. The `value` attribute, at the time, was holding the error
message. Nowadays it is no more used.
The `osv` module contains very old deprecated aliases. There is no
simple way to log a deprecation warning for osv, osv_memory and
osv_abstract but as they have not been in use for ages, they have been
removed too. To be consistent, the `--osv-memory-age-limit` cli option
has been made a deprecated alias to the `--transient-age-limit`.
closes odoo/odoo#45723
Task: 2187728
Related: odoo/enterprise#9162
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/services/crash_manager.js | 78 |
1 files changed, 25 insertions, 53 deletions
diff --git a/addons/web/static/src/js/services/crash_manager.js b/addons/web/static/src/js/services/crash_manager.js index 19db73e1da5..b653aaa1c8d 100644 --- a/addons/web/static/src/js/services/crash_manager.js +++ b/addons/web/static/src/js/services/crash_manager.js @@ -87,6 +87,13 @@ var CrashManager = AbstractService.extend({ var self = this; active = true; this.isConnected = true; + this.odooExceptionTitleMap = { + 'odoo.exceptions.AccessDenied': _lt("Access Denied"), + 'odoo.exceptions.AccessError': _lt("Access Error"), + 'odoo.exceptions.MissingError': _lt("Missing Record"), + 'odoo.exceptions.UserError': _lt("User Error"), + 'odoo.exceptions.ValidationError': _lt("Validation Error"), + }; this._super.apply(this, arguments); @@ -180,70 +187,35 @@ var CrashManager = AbstractService.extend({ rpc_error: function(error) { // Some qunit tests produces errors before the DOM is set. // This produces an error loop as the modal/toast has no DOM to attach to. - if (!document.body) { - return; - } - var map_title = { - access_denied: _lt("Access Denied"), - access_error: _lt("Access Error"), - except_orm: _lt("Global Business Error"), - missing_error: _lt("Missing Record"), - user_error: _lt("User Error"), - validation_error: _lt("Validation Error"), - warning: _lt("Warning"), - }; - if (!active) { - return; - } - if (this.connection_lost) { - return; - } + if (!document.body || !active || this.connection_lost) return; + + // Connection lost error if (error.code === -32098) { this.handleLostConnection(); return; } + + // Special exception handlers, see crash_registry bellow var handler = core.crash_registry.get(error.data.name, true); if (handler) { new (handler)(this, error).display(); return; } - if (_.has(map_title, error.data.exception_type)) { - if (error.data.exception_type === 'except_orm') { - if (error.data.arguments[1]) { - error = _.extend({}, error, - { - data: _.extend({}, error.data, - { - message: error.data.arguments[1], - title: error.data.arguments[0] !== 'Warning' ? error.data.arguments[0] : '', - }) - }); - } - else { - error = _.extend({}, error, - { - data: _.extend({}, error.data, - { - message: error.data.arguments[0], - title: '', - }) - }); - } - } - else { - error = _.extend({}, error, - { - data: _.extend({}, error.data, - { - message: error.data.arguments[0], - title: map_title[error.data.exception_type] !== 'Warning' ? map_title[error.data.exception_type] : '', - }) - }); - } + + // Odoo custom exception: UserError, AccessError, ... + if (_.has(this.odooExceptionTitleMap, error.data.name)) { + error = _.extend({}, error, { + data: _.extend({}, error.data, { + message: error.data.arguments[0], + title: this.odooExceptionTitleMap[error.data.name], + }), + }); this.show_warning(error); - } else { - this.show_error(error); + return; } + + // Any other Python exception + this.show_error(error); }, show_warning: function (error, options) { if (!active) { |
