mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-28 12:37:00 +00:00
core: Only catch errors from onBeforeUpload
Previously this code would treat any error at all as an `onBeforeUpload` error, and show the informer. We also lost the stack trace for errors because `err` is stringified in the handler. This is correct for `onBeforeUpload` rejections, since they are string reasons, but not for other errors. Now only actual `onBeforeUpload` errors are handled that way, and fatal upload errors end up in the StatusBar like before and in the console, with a stack trace.
This commit is contained in:
parent
b042bb9f93
commit
62c264500a
1 changed files with 4 additions and 5 deletions
|
|
@ -669,7 +669,10 @@ class Uppy {
|
|||
return Promise.reject('Minimum number of files has not been reached')
|
||||
}
|
||||
|
||||
return this.opts.onBeforeUpload(this.getState().files).then(() => {
|
||||
return this.opts.onBeforeUpload(this.getState().files).catch((err) => {
|
||||
this.emit('informer', err, 'error', 5000)
|
||||
return Promise.reject(`onBeforeUpload: ${err}`)
|
||||
}).then(() => {
|
||||
this.emit('core:upload')
|
||||
|
||||
const waitingFileIDs = []
|
||||
|
|
@ -700,10 +703,6 @@ class Uppy {
|
|||
this.emit('core:success', waitingFileIDs)
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
this.emit('informer', err, 'error', 5000)
|
||||
return Promise.reject(`onBeforeUpload: ${err}`)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue