瀏覽代碼

return fileId or error in plugin.addFile (#2919)

In the case of an invalid URL, this is no proper way to handle an error. `uppy.state.info` only show the error without any info that due to which URL error was thrown. 
So returning the error or file so it can be handled as need. throwing the error will not be backward compatible
Nilesh Suthar 3 年之前
父節點
當前提交
7d5bdddaa6
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      packages/@uppy/url/src/index.js

+ 3 - 1
packages/@uppy/url/src/index.js

@@ -150,11 +150,12 @@ module.exports = class Url extends Plugin {
       .then((tagFile) => {
       .then((tagFile) => {
         this.uppy.log('[Url] Adding remote file')
         this.uppy.log('[Url] Adding remote file')
         try {
         try {
-          this.uppy.addFile(tagFile)
+          return this.uppy.addFile(tagFile)
         } catch (err) {
         } catch (err) {
           if (!err.isRestriction) {
           if (!err.isRestriction) {
             this.uppy.log(err)
             this.uppy.log(err)
           }
           }
+          return err
         }
         }
       })
       })
       .catch((err) => {
       .catch((err) => {
@@ -163,6 +164,7 @@ module.exports = class Url extends Plugin {
           message: this.i18n('failedToFetch'),
           message: this.i18n('failedToFetch'),
           details: err,
           details: err,
         }, 'error', 4000)
         }, 'error', 4000)
+        return err
       })
       })
   }
   }