Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Only catch errors from onBeforeUpload #246

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/core/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ class Uppy {
}

addFile (file) {
return this.opts.onBeforeFileAdded(file, this.getState().files).then(() => {
return this.opts.onBeforeFileAdded(file, this.getState().files).catch((err) => {
this.emit('informer', err, 'error', 5000)
return Promise.reject(`onBeforeFileAdded: ${err}`)
}).then(() => {
return Utils.getFileType(file).then((fileType) => {
const updatedFiles = Object.assign({}, this.state.files)
const fileName = file.name || 'noname'
Expand Down Expand Up @@ -288,10 +291,6 @@ class Uppy {
}
})
})
.catch((err) => {
this.emit('informer', err, 'error', 5000)
return Promise.reject(`onBeforeFileAdded: ${err}`)
})
}

removeFile (fileID) {
Expand Down Expand Up @@ -669,7 +668,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 = []
Expand Down Expand Up @@ -700,10 +702,6 @@ class Uppy {
this.emit('core:success', waitingFileIDs)
})
})
.catch((err) => {
this.emit('informer', err, 'error', 5000)
return Promise.reject(`onBeforeUpload: ${err}`)
})
}
}

Expand Down