diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-05-29 17:34:43 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-05-29 17:34:43 +0200 |
| commit | f36e6917bd73a56dc0c7468b4849920df4088154 (patch) | |
| tree | b63d02ae3e5ffc0815de009407363e0cf906f547 /addons/web/static/src/js/core/ajax.js | |
| parent | bc0173c2d58ac26d80cb2f483a95c0c13b047dab (diff) | |
| parent | 37eed7c509fb5846c89ef37046df4b3cab299719 (diff) | |
[MERGE] forward port branch saas-11.3 up to 37eed7c509f
Diffstat (limited to 'addons/web/static/src/js/core/ajax.js')
| -rw-r--r-- | addons/web/static/src/js/core/ajax.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/addons/web/static/src/js/core/ajax.js b/addons/web/static/src/js/core/ajax.js index 0ee6d2ad1ed..d6c67eacaec 100644 --- a/addons/web/static/src/js/core/ajax.js +++ b/addons/web/static/src/js/core/ajax.js @@ -260,8 +260,20 @@ function get_file(options) { if (options.error) { var body = this.contentDocument.body; var nodes = body.children.length === 0 ? body.childNodes : body.children; - var node = nodes[1] || nodes[0]; - options.error(JSON.parse(node.textContent)); + var errorParams = {}; + + try { // Case of a serialized Odoo Exception: It is Json Parsable + var node = nodes[1] || nodes[0]; + errorParams = JSON.parse(node.textContent); + } catch (e) { // Arbitrary uncaught python side exception + errorParams = { + message: nodes.length > 1 ? nodes[1].textContent : '', + data: { + title: nodes.length > 0 ? nodes[0].textContent : '', + } + } + } + options.error(errorParams); } } finally { complete(); |
