summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2013-01-30 17:15:34 +0100
committerniv-openerp <nicolas.vanhoren@openerp.com>2013-01-30 17:15:34 +0100
commitbd3d0384fd49ecdf70ca4001e629d0e05d6f5191 (patch)
tree758e0e1f4b44e571a725b3693a978467d31ae6cf /addons/web/static/src/js
parent4cd744d3f844633ef2cfc8f69bbd22938a8d9fa7 (diff)
[IMP] added mechanism to implement exception handlers
bzr revid: nicolas.vanhoren@openerp.com-20130130161534-m81tj4h3dgsoprh3
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/chrome.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index bdc1dd4c02c..1407df4d33f 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -247,6 +247,11 @@ instance.web.CrashManager = instance.web.Class.extend({
if (!this.active) {
return;
}
+ var handler = instance.web.crash_manager_registry.get_object(error.data.name, true);
+ if (handler) {
+ new (handler)(this, error).display();
+ return;
+ };
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;
@@ -299,6 +304,29 @@ instance.web.CrashManager = instance.web.Class.extend({
},
});
+/**
+ An interface to implement to handle exceptions. Register implementation in instance.web.crash_manager_registry.
+*/
+instance.web.ExceptionHandler = {
+ /**
+ @param parent The parent.
+ @param error The error object as returned by the JSON-RPC implementation.
+ */
+ init: function(parent, error) {},
+ /**
+ Called to inform to display the widget, if necessary. A typical way would be to implement
+ this interface in a class extending instance.web.Dialog and simply display the dialog in this
+ method.
+ */
+ display: function() {},
+};
+
+/**
+ The registry to handle exceptions. It associate a fully qualified python exception name with a class implementing
+ instance.web.ExceptionHandler.
+*/
+instance.web.crash_manager_registry = new instance.web.Registry();
+
instance.web.Loading = instance.web.Widget.extend({
template: _t("Loading"),
init: function(parent) {