mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
closes #6166
This commit is contained in:
@@ -82,20 +82,23 @@ module.exports = function (Plugins) {
|
|||||||
|
|
||||||
var hookList = Plugins.loadedHooks[hook];
|
var hookList = Plugins.loadedHooks[hook];
|
||||||
var hookType = hook.split(':')[0];
|
var hookType = hook.split(':')[0];
|
||||||
|
try {
|
||||||
switch (hookType) {
|
switch (hookType) {
|
||||||
case 'filter':
|
case 'filter':
|
||||||
fireFilterHook(hook, hookList, params, callback);
|
fireFilterHook(hook, hookList, params, callback);
|
||||||
break;
|
break;
|
||||||
case 'action':
|
case 'action':
|
||||||
fireActionHook(hook, hookList, params, callback);
|
fireActionHook(hook, hookList, params, callback);
|
||||||
break;
|
break;
|
||||||
case 'static':
|
case 'static':
|
||||||
fireStaticHook(hook, hookList, params, callback);
|
fireStaticHook(hook, hookList, params, callback);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
winston.warn('[plugins] Unknown hookType: ' + hookType + ', hook : ' + hook);
|
winston.warn('[plugins] Unknown hookType: ' + hookType + ', hook : ' + hook);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
callback(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,20 @@ describe('Plugins', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not crash if there is an exception in a hook', function (done) {
|
||||||
|
function filterMethod(data, callback) {
|
||||||
|
var crash;
|
||||||
|
crash.a = 5;
|
||||||
|
callback(null, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
assert(err);
|
||||||
|
assert.equal(err.message, 'Cannot set property \'a\' of undefined');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should get plugin data from nbbpm', function (done) {
|
it('should get plugin data from nbbpm', function (done) {
|
||||||
plugins.get('nodebb-plugin-markdown', function (err, data) {
|
plugins.get('nodebb-plugin-markdown', function (err, data) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user