From e9cd03e90cb4a71d03b2dfa95489add7eaf2f37a Mon Sep 17 00:00:00 2001 From: "silver%warwickcompsoc.co.uk" Date: Wed, 27 Jul 2005 15:59:30 +0000 Subject: [PATCH] Bug 274300 - Catch and handle hook processing errors in event queue. ChatZilla only. r=rginda a=bsmedberg --- extensions/irc/js/lib/events.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/extensions/irc/js/lib/events.js b/extensions/irc/js/lib/events.js index 567eb3188648..314a91e90f7e 100644 --- a/extensions/irc/js/lib/events.js +++ b/extensions/irc/js/lib/events.js @@ -22,6 +22,7 @@ * * Contributor(s): * Robert Ginda, rginda@ndcico.com, original author + * James Ross, silver@warwickcompsoc.co.uk * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -43,7 +44,6 @@ function CEvent (set, type, destObject, destMethod) { - this.set = set; this.type = type; this.destObject = destObject; @@ -57,7 +57,6 @@ function CEvent (set, type, destObject, destMethod) */ function CEventPump (eventsPerStep) { - /* event routing stops after this many levels, safety valve */ this.MAX_EVENT_DEPTH = 50; /* When there are this many 'used' items in a queue, always clean up. At @@ -102,14 +101,24 @@ function ep_hook(e, hooks) !matchObject (e, hooks[h].pattern, hooks[h].neg)) continue hook_loop; - e.hooks.push (hooks[h]); - var rv = hooks[h].f(e); + e.hooks.push(hooks[h]); + try + { + var rv = hooks[h].f(e); + } + catch(ex) + { + dd("hook #" + h + " '" + + ((typeof hooks[h].name != "undefined") ? hooks[h].name : + "") + "' had an error!"); + dd(formatException(ex)); + } if ((typeof rv == "boolean") && (rv == false)) { - dd ("hook #" + h + " '" + - ((typeof hooks[h].name != "undefined") ? hooks[h].name : - "") + "' stopped hook processing."); + dd("hook #" + h + " '" + + ((typeof hooks[h].name != "undefined") ? hooks[h].name : + "") + "' stopped hook processing."); return true; } } @@ -345,6 +354,6 @@ function ep_stepevents() this.bulkQueuePointer = 0; } - return true; + return i; }