Skip to content

Commit

Permalink
[update] throw plugin name if you install ilegal plugin
Browse files Browse the repository at this point in the history
What:
Why:
How:
  • Loading branch information
toxic-johann committed Aug 2, 2017
1 parent 07ced66 commit a9d833d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion __tests__/dispatcher/index.js
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/dispatcher/index.js
Expand Up @@ -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;
}
Expand Down

0 comments on commit a9d833d

Please sign in to comment.