Browse Source

Merge pull request #302 from goto-bus-stop/feature/clearer-plugin-error

core: Throw clearer error when `.use`ing undefined
Artur Paikin 7 years ago
parent
commit
a086458bf1
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/core/Core.js

+ 6 - 0
src/core/Core.js

@@ -601,6 +601,12 @@ class Uppy {
  * @return {Object} self for chaining
  * @return {Object} self for chaining
  */
  */
   use (Plugin, opts) {
   use (Plugin, opts) {
+    if (typeof Plugin !== 'function') {
+      let msg = `Expected a plugin class, but got ${Plugin === null ? 'null' : typeof Plugin}.` +
+        ' Please verify that the plugin was imported and spelled correctly.'
+      throw new TypeError(msg)
+    }
+
     // Instantiate
     // Instantiate
     const plugin = new Plugin(this, opts)
     const plugin = new Plugin(this, opts)
     const pluginName = plugin.id
     const pluginName = plugin.id