Better plugin error handling

This commit is contained in:
Egil Moeller 2012-02-25 13:37:47 +01:00
parent a89c81f62f
commit 26d9c3ed53
2 changed files with 20 additions and 5 deletions

View file

@ -80,7 +80,12 @@ exports.extractHooks = function (parts) {
Object.keys(part.hooks || {}).forEach(function (hook_name) {
if (hooks[hook_name] === undefined) hooks[hook_name] = [];
var hook_fn_name = part.hooks[hook_name];
hooks[hook_name].push({"hook": exports.loadFn(part.hooks[hook_name]), "part": part});
var hook_fn = exports.loadFn(part.hooks[hook_name]);
if (hook_fn) {
hooks[hook_name].push({"hook": hook_fn, "part": part});
} else {
console.error("Unable to load hook function for " + part.full_name + " for hook " + hook_name + ": " + part.hooks[hook_name]);
}
});
});
return hooks;