core: provide default error message (#1880)

We were already doing `if (file.error)` in places, now that is
guaranteed to work even if the error message was empty or the error
object is custom and doesn't have a `.message` property.
This commit is contained in:
Renée Kooi 2019-10-11 16:42:40 +02:00 committed by GitHub
parent d3e8779d36
commit 50bbeb0245
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -783,12 +783,12 @@ class Uppy {
*/
_addListeners () {
this.on('error', (error) => {
this.setState({ error: error.message })
this.setState({ error: error.message || 'Unknown error' })
})
this.on('upload-error', (file, error, response) => {
this.setFileState(file.id, {
error: error.message,
error: error.message || 'Unknown error',
response
})