From a9d833dd89c077502335876201d637ec1ae99d4d Mon Sep 17 00:00:00 2001 From: toxic-johann Date: Wed, 2 Aug 2017 12:14:48 +0800 Subject: [PATCH] [update] throw plugin name if you install ilegal plugin What: Why: How: --- __tests__/dispatcher/index.js | 2 +- src/dispatcher/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/__tests__/dispatcher/index.js b/__tests__/dispatcher/index.js index 9be7c86..a9d3e40 100644 --- a/__tests__/dispatcher/index.js +++ b/__tests__/dispatcher/index.js @@ -35,7 +35,7 @@ describe('dispatcher', () => { expect(() => Dispatcher.install({})).toThrow("plugin's config must be an Object"); expect(() => Dispatcher.install({name: ''})).toThrow('plugin must have a legal name'); expect(() => Dispatcher.install({name: 1})).toThrow('plugin must have a legal name'); - expect(() => Dispatcher.install(class Illegal {})).toThrow('If you pass a function as plugin config, this class must extends from Chimee.plugin'); + expect(() => Dispatcher.install(class Illegal {})).toThrow("Your are trying to install plugin Illegal, but it's not extends from Chimee.plugin."); expect(Dispatcher.install(normalInstall)).toBe('normalInstall'); expect(Dispatcher.install(NormalFunctionInstall)).toBe('normalFunctionInstall'); expect(Dispatcher.install(GrandSon)).toBe('grandSon'); diff --git a/src/dispatcher/index.js b/src/dispatcher/index.js index 73dac20..5ed34ad 100644 --- a/src/dispatcher/index.js +++ b/src/dispatcher/index.js @@ -14,7 +14,7 @@ function convertNameIntoId (name: string): string { function checkPluginConfig (config: any) { if(isFunction(config)) { if(!(config.prototype instanceof Plugin)) { - throw new TypeError('If you pass a function as plugin config, this class must extends from Chimee.plugin'); + throw new TypeError(`Your are trying to install plugin ${config.name}, but it's not extends from Chimee.plugin.`); } return; }