Selaa lähdekoodia

Merge pull request #1488 from transloadit/feature/assembly-error

transloadit: add assembly status property to assembly errors
Renée Kooi 6 vuotta sitten
vanhempi
commit
79e1e80046
2 muutettua tiedostoa jossa 15 lisäystä ja 2 poistoa
  1. 2 1
      packages/@uppy/transloadit/src/index.js
  2. 13 1
      website/src/docs/transloadit.md

+ 2 - 1
packages/@uppy/transloadit/src/index.js

@@ -471,6 +471,7 @@ module.exports = class Transloadit extends Plugin {
       this._onFileUploadComplete(id, file)
       this._onFileUploadComplete(id, file)
     })
     })
     assembly.on('error', (error) => {
     assembly.on('error', (error) => {
+      error.assembly = assembly.status
       this.uppy.emit('transloadit:assembly-error', assembly.status, error)
       this.uppy.emit('transloadit:assembly-error', assembly.status, error)
     })
     })
 
 
@@ -610,7 +611,7 @@ module.exports = class Transloadit extends Plugin {
       return Promise.resolve()
       return Promise.resolve()
     }
     }
 
 
-    // AssemblyWatcher tracks completion state of all Assemblies in this upload.
+    // AssemblyWatcher tracks completion states of all Assemblies in this upload.
     const watcher = new AssemblyWatcher(this.uppy, assemblyIDs)
     const watcher = new AssemblyWatcher(this.uppy, assemblyIDs)
 
 
     fileIDs.forEach((fileID) => {
     fileIDs.forEach((fileID) => {

+ 13 - 1
website/src/docs/transloadit.md

@@ -10,7 +10,7 @@ category: 'File Processing'
 The `@uppy/transloadit` plugin can be used to upload files to [Transloadit](https://transloadit.com/) for all kinds of processing, such as transcoding video, resizing images, zipping/unzipping, [and much more](https://transloadit.com/services/).
 The `@uppy/transloadit` plugin can be used to upload files to [Transloadit](https://transloadit.com/) for all kinds of processing, such as transcoding video, resizing images, zipping/unzipping, [and much more](https://transloadit.com/services/).
 
 
 > If you're okay to trade some flexibility for ergonomics, consider using
 > If you're okay to trade some flexibility for ergonomics, consider using
-> the [Robodog](/docs/robodog/) Plugin instead, which is a higher-level abstraction for 
+> the [Robodog](/docs/robodog/) Plugin instead, which is a higher-level abstraction for
 > encoding files with Uppy and Transloadit.
 > encoding files with Uppy and Transloadit.
 
 
 <a class="TryButton" href="/examples/transloadit/">Try it live</a>
 <a class="TryButton" href="/examples/transloadit/">Try it live</a>
@@ -274,6 +274,18 @@ strings: {
 }
 }
 ```
 ```
 
 
+## Errors
+
+If an error occurs when an Assembly has already started, you can find the Assembly Status on the error object's `assembly` property.
+
+```js
+uppy.on('error', (error) => {
+  if (error.assembly) {
+    console.log(`${error.assembly.assembly_id} failed!`)
+  }
+})
+```
+
 ## Events
 ## Events
 
 
 ### `transloadit:assembly-created`
 ### `transloadit:assembly-created`