core: Prevent unhandled rejection warnings in addFile()

This commit is contained in:
Renée Kooi 2018-02-05 14:40:38 +01:00
parent 5537bf4038
commit 26cafb1afe
No known key found for this signature in database
GPG key ID: 8CDD5F0BC448F040

View file

@ -389,7 +389,13 @@ class Uppy {
.catch((err) => {
const message = typeof err === 'object' ? err.message : err
this.info(message, 'error', 5000)
return Promise.reject(typeof err === 'object' ? err : new Error(err))
const rejected = Promise.reject(typeof err === 'object' ? err : new Error(err))
// Silence the unhandled rejection; we have already shown it to the user,
// so the consumer may not need to do anything with this result.
// Note that the result is still a rejected Promise, it will just not
// trigger unhandled rejection warnings in the browser console.
rejected.catch(() => {})
return rejected
})
}