Bladeren bron

Add error handling for bad Plugin use

Kevin van Zonneveld 9 jaren geleden
bovenliggende
commit
e587e248a6
1 gewijzigde bestanden met toevoegingen van 8 en 0 verwijderingen
  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