瀏覽代碼

Pass through errors (#185)

* Transloadit: pass through assembly errors.

* Bubble up upload errors to a `core:err~or` event
Renée Kooi 8 年之前
父節點
當前提交
b90eeec6b8
共有 3 個文件被更改,包括 15 次插入0 次删除
  1. 6 0
      src/core/Core.js
  2. 4 0
      src/plugins/Transloadit/Socket.js
  3. 5 0
      src/plugins/Transloadit/index.js

+ 6 - 0
src/core/Core.js

@@ -527,6 +527,12 @@ class Uppy {
       promise = promise.then(() => fn())
       promise = promise.then(() => fn())
     })
     })
 
 
+    // Not returning the `catch`ed promise, because we still want to return a rejected
+    // promise from this method if the upload failed.
+    promise.catch((err) => {
+      this.emit('core:error', err)
+    })
+
     return promise.then(() => {
     return promise.then(() => {
       this.emit('core:success')
       this.emit('core:success')
     })
     })

+ 4 - 0
src/plugins/Transloadit/Socket.js

@@ -44,6 +44,10 @@ module.exports = class TransloaditSocket {
     this.socket.on('assembly_result_finished', (stepName, result) => {
     this.socket.on('assembly_result_finished', (stepName, result) => {
       this.emit('result', stepName, result)
       this.emit('result', stepName, result)
     })
     })
+
+    this.socket.on('assembly_error', (err) => {
+      this.emit('error', Object.assign(new Error(err.message), err))
+    })
   }
   }
 
 
   close () {
   close () {

+ 5 - 0
src/plugins/Transloadit/index.js

@@ -160,6 +160,11 @@ module.exports = class Transloadit extends Plugin {
       // which result to pick…?
       // which result to pick…?
 
 
       this.core.emit('informer:hide')
       this.core.emit('informer:hide')
+    }).catch((err) => {
+      // Always hide the Informer
+      this.core.emit('informer:hide')
+
+      throw err
     })
     })
   }
   }