trap exceptions when running hooks, log the error, and continue

should reduce issues caused when plugins are broken
This commit is contained in:
Jon Atkins 2013-09-05 03:42:36 +01:00
parent 0f37bc8ef6
commit ac9d9cfaf0

View File

@ -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;