Bläddra i källkod

Add error handling for bad Plugin use

Kevin van Zonneveld 9 år sedan
förälder
incheckning
e587e248a6
1 ändrade filer med 8 tillägg och 0 borttagningar
  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