summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/core/ajax.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-05-18 18:59:06 +0200
committerChristophe Simonis <chs@odoo.com>2018-05-18 18:59:06 +0200
commit8383181b8f74c87c43bc6b8c97d84e550d5d89c4 (patch)
tree9184a391e492bebf64cc0d1dbe5ffcaa7d7b0fbd /addons/web/static/src/js/core/ajax.js
parent8ac98fc78a3794e06481b02a431bcdc386a5a6ee (diff)
parent021d0e6a98bb9baa0d554d4e8b5717c7893a7641 (diff)
[MERGE] forward port branch saas-15 up to 021d0e6a98b
Diffstat (limited to 'addons/web/static/src/js/core/ajax.js')
-rw-r--r--addons/web/static/src/js/core/ajax.js20
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();