diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-05-23 19:33:40 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-05-23 19:33:40 +0200 |
| commit | 2bc6ea1b378bc8a660219b0502c93118f0bb1b6a (patch) | |
| tree | 806acef55473ca422ca6f1d5d46041e3c5e1e590 /addons/web/static/src/js/core | |
| parent | 2a43614c3c00d57a4376eea44cd8cd1ed2d316b7 (diff) | |
| parent | 02ee3fd88eff00ecc058c060aa9b3b39b7c08e15 (diff) | |
[MERGE] forward port branch 11.0 up to 02ee3fd88ef
Diffstat (limited to 'addons/web/static/src/js/core')
| -rw-r--r-- | addons/web/static/src/js/core/ajax.js | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/addons/web/static/src/js/core/ajax.js b/addons/web/static/src/js/core/ajax.js index 2912b319df2..d6c67eacaec 100644 --- a/addons/web/static/src/js/core/ajax.js +++ b/addons/web/static/src/js/core/ajax.js @@ -260,12 +260,20 @@ function get_file(options) { if (options.error) { var body = this.contentDocument.body; var nodes = body.children.length === 0 ? body.childNodes : body.children; - options.error({ - message: nodes.length > 1 ? nodes[1].textContent : '', - data: { - title: nodes.length > 0 ? nodes[0].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(); |
