diff --git a/addons/web/http.py b/addons/web/http.py index 7a1c1bcb4af..663acee9ebc 100644 --- a/addons/web/http.py +++ b/addons/web/http.py @@ -232,12 +232,21 @@ class JsonRequest(WebRequest): return r def serialize_exception(e): - return { + tmp = { "name": type(e).__module__ + "." + type(e).__name__ if type(e).__module__ else type(e).__name__, "debug": traceback.format_exc(), "message": u"%s" % e, "arguments": to_jsonable(e.args), } + if isinstance(e, openerp.osv.osv.except_osv): + tmp["exception_type"] = "except_osv" + elif isinstance(e, openerp.exceptions.Warning): + tmp["exception_type"] = "warning" + elif isinstance(e, openerp.exceptions.AccessError): + tmp["exception_type"] = "access_error" + elif isinstance(e, openerp.exceptions.AccessDenied): + tmp["exception_type"] = "access_denied" + return tmp def to_jsonable(o): if isinstance(o, str) or isinstance(o,unicode) or isinstance(o, int) or isinstance(o, long) \ diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index f2de7e61eab..bdc1dd4c02c 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -247,19 +247,12 @@ instance.web.CrashManager = instance.web.Class.extend({ if (!this.active) { return; } - // yes, exception handling is shitty - if (error.code === 300 && error.data && error.data.type == "client_exception" && error.data.debug.match("SessionExpiredException")) { - this.show_warning({type: "Session Expired", data: { fault_code: "Your OpenERP session expired. Please refresh the current web page." }}); + if (error.data.name === "openerp.addons.web.session SessionExpiredException") { + this.show_warning({type: "Session Expired", data: { message: "Your OpenERP session expired. Please refresh the current web page." }}); return; } - if (error.data.fault_code) { - var split = ("" + error.data.fault_code).split('\n')[0].split(' -- '); - if (split.length > 1) { - error.type = split.shift(); - error.data.fault_code = error.data.fault_code.substr(error.type.length + 4); - } - } - if (error.code === 200 && error.type) { + if (error.data.exception_type === "except_osv" || error.data.exception_type === "warning" + || error.data.exception_type === "access_error") { this.show_warning(error); } else { this.show_error(error); @@ -269,8 +262,11 @@ instance.web.CrashManager = instance.web.Class.extend({ if (!this.active) { return; } + if (error.data.exception_type === "except_osv") { + error = _.extend({}, error, {data: _.extend({}, error.data, {message: error.data.arguments[0] + "\n\n" + error.data.arguments[1]})}); + } instance.web.dialog($('
');