From ac9d9cfaf0571edb6722711194ff9d2e021ab334 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Thu, 5 Sep 2013 03:42:36 +0100 Subject: [PATCH] trap exceptions when running hooks, log the error, and continue should reduce issues caused when plugins are broken --- code/hooks.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/code/hooks.js b/code/hooks.js index 17b15444..4b66dcc0 100644 --- a/code/hooks.js +++ b/code/hooks.js @@ -60,9 +60,13 @@ window.runHooks = function(event, data) { if(!_hooks[event]) return true; var interupted = false; $.each(_hooks[event], function(ind, callback) { - if (callback(data) === false) { - interupted = true; - return false; //break from $.each + try { + if (callback(data) === false) { + interupted = true; + return false; //break from $.each + } + } catch(err) { + console.error('error running hook '+event+', error: '+err); } }); return !interupted;