瀏覽代碼

Add error handling for bad Plugin use

Kevin van Zonneveld 9 年之前
父節點
當前提交
e587e248a6
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      src/core/Core.js

+ 8 - 0
src/core/Core.js

@@ -47,6 +47,14 @@ export default class Core {
     // Instantiate
     const plugin = new Plugin(this, opts)
     this.plugins[plugin.type] = this.plugins[plugin.type] || []
+
+    if (!plugin.name) {
+      throw new Error('Your plugin must have a name')
+    }
+    if (!plugin.type) {
+      throw new Error('Your plugin must have a type')
+    }
+
     this.plugins[plugin.type].push(plugin)
 
     return this