trap exceptions when running hooks, log the error, and continue
should reduce issues caused when plugins are broken
This commit is contained in:
parent
0f37bc8ef6
commit
ac9d9cfaf0
@ -60,9 +60,13 @@ window.runHooks = function(event, data) {
|
|||||||
if(!_hooks[event]) return true;
|
if(!_hooks[event]) return true;
|
||||||
var interupted = false;
|
var interupted = false;
|
||||||
$.each(_hooks[event], function(ind, callback) {
|
$.each(_hooks[event], function(ind, callback) {
|
||||||
if (callback(data) === false) {
|
try {
|
||||||
interupted = true;
|
if (callback(data) === false) {
|
||||||
return false; //break from $.each
|
interupted = true;
|
||||||
|
return false; //break from $.each
|
||||||
|
}
|
||||||
|
} catch(err) {
|
||||||
|
console.error('error running hook '+event+', error: '+err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return !interupted;
|
return !interupted;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user