Ver Fonte

transloadit: propagate error details when creating Assembly fails (#3794)

* transloadit: propagate error details when creating Assembly fails

Clients are expected to use `error.assembly` to inspect details about
failed Assemblies, but then we do need to always give that property
back.

I think we should have a test for this but not sure how to approach it,
since it depends on responses from the Transloadit API. I guess we'd
require a new e2e test for it?

* Apply suggestions from code review

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Renée Kooi há 2 anos atrás
pai
commit
3121fae11b
1 ficheiros alterados com 8 adições e 1 exclusões
  1. 8 1
      packages/@uppy/transloadit/src/index.js

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

@@ -242,7 +242,14 @@ export default class Transloadit extends BasePlugin {
       this.uppy.log(`[Transloadit] Created Assembly ${assemblyID}`)
       return assembly
     }).catch((err) => {
-      throw new ErrorWithCause(`${this.i18n('creatingAssemblyFailed')}: ${err.message}`, { cause: err })
+      const wrapped = new ErrorWithCause(`${this.i18n('creatingAssemblyFailed')}: ${err.message}`, { cause: err })
+      if ('details' in err) {
+        wrapped.details = err.details
+      }
+      if ('assembly' in err) {
+        wrapped.assembly = err.assembly
+      }
+      throw wrapped
     })
   }