From 9c71d984e6937cc598fc8da52bf353322acc03cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Wed, 10 Oct 2012 11:55:09 +0200 Subject: [IMP] Class instanciations throws an error when you forgot to use the new operator bzr revid: fva@openerp.com-20121010095509-ojvigsva4hblta7m --- addons/web/static/src/js/corelib.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'addons/web/static/src/js/corelib.js') diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index ff193605033..21d593069e7 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -121,6 +121,10 @@ openerp.web.corelib = function(instance) { // The dummy class constructor function Class() { + if(this.constructor !== instance.web.Class){ + throw new Error("You need a 'new' to instanciate an object"); + return null; + } // All construction is actually done in the init method if (!initializing && this.init) { var ret = this.init.apply(this, arguments); -- cgit v1.2.3 From 21dcc15a2ca38725d963fd16f57f5c9f4b1c5afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Wed, 10 Oct 2012 12:44:33 +0200 Subject: [FIX] previous 'forgot now' error message was a bit crappy bzr revid: fva@openerp.com-20121010104433-cb03lb11fi15qrzd --- addons/web/static/src/js/corelib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/corelib.js') diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index 21d593069e7..7a9af79b4fb 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -122,7 +122,7 @@ openerp.web.corelib = function(instance) { // The dummy class constructor function Class() { if(this.constructor !== instance.web.Class){ - throw new Error("You need a 'new' to instanciate an object"); + throw new Error("You can only instanciate objects with the 'new' operator"); return null; } // All construction is actually done in the init method -- cgit v1.2.3 From f44ea704fe562dc346b280c6f546e5bc8d630387 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 11 Oct 2012 02:37:29 +0200 Subject: [IMP] CrashManager use event dispatcher and cleanups bzr revid: al@openerp.com-20121011003729-jjbh5se1cpsachvm --- addons/web/static/src/js/corelib.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src/js/corelib.js') diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index 7a9af79b4fb..b5fbacc7927 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -980,7 +980,8 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({ triggers: { 'request': 'Request sent', 'response': 'Response received', - 'error': 'HTTP Error response or timeout received', + 'response_failed': 'HTTP Error response or timeout received', + 'error': 'The received response is an JSON-RPC error', }, /** * @constructs instance.web.JsonRPC @@ -1336,7 +1337,7 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({ } }, function(jqXHR, textStatus, errorThrown) { - self.trigger('error'); + self.trigger('response_failed', jqXHR); var error = { code: -32098, message: "XmlHttpRequestError " + errorThrown, @@ -1348,7 +1349,7 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({ deferred.fail(function() { deferred.fail(function(error, event) { if (!event.isDefaultPrevented()) { - self.on_rpc_error(error, event); + self.trigger('error', error, event); } }); }); @@ -1434,8 +1435,6 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({ return deferred; } }, - on_rpc_error: function(error) { - }, get_url: function (file) { return this.prefix + file; }, -- cgit v1.2.3