mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-25 03:08:34 +00:00
Catch addFile() errors in UI plugins
Prevents warnings in the console about unhandled rejections. We can safely catch and ignore these errors, because they also show up in the UI already anyway.
This commit is contained in:
parent
26cafb1afe
commit
4b24537a08
7 changed files with 23 additions and 11 deletions
|
|
@ -389,13 +389,7 @@ class Uppy {
|
|||
.catch((err) => {
|
||||
const message = typeof err === 'object' ? err.message : err
|
||||
this.info(message, 'error', 5000)
|
||||
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
|
||||
return Promise.reject(typeof err === 'object' ? err : new Error(err))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -277,6 +277,8 @@ module.exports = class Dashboard extends Plugin {
|
|||
name: file.name,
|
||||
type: file.type,
|
||||
data: blob
|
||||
}).catch(() => {
|
||||
// Ignore
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
@ -291,6 +293,8 @@ module.exports = class Dashboard extends Plugin {
|
|||
name: file.name,
|
||||
type: file.type,
|
||||
data: file
|
||||
}).catch(() => {
|
||||
// Ignore
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
@ -360,6 +364,8 @@ module.exports = class Dashboard extends Plugin {
|
|||
name: file.name,
|
||||
type: file.type,
|
||||
data: file
|
||||
}).catch(() => {
|
||||
// Ignore
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ module.exports = class DragDrop extends Plugin {
|
|||
name: file.name,
|
||||
type: file.type,
|
||||
data: file
|
||||
}).catch(() => {
|
||||
// Ignore
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
@ -98,6 +100,8 @@ module.exports = class DragDrop extends Plugin {
|
|||
name: file.name,
|
||||
type: file.type,
|
||||
data: file
|
||||
}).catch(() => {
|
||||
// Ignore
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ module.exports = class Dummy extends Plugin {
|
|||
data: blob
|
||||
}
|
||||
this.props.log('Adding fake file blob')
|
||||
this.props.addFile(file)
|
||||
this.props.addFile(file).catch(() => {
|
||||
// Ignore
|
||||
})
|
||||
}
|
||||
|
||||
render (state) {
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ module.exports = class FileInput extends Plugin {
|
|||
name: file.name,
|
||||
type: file.type,
|
||||
data: file
|
||||
}).catch(() => {
|
||||
// Ignore
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,7 +169,9 @@ module.exports = class View {
|
|||
tagFile.preview = this.plugin.getItemThumbnailUrl(file)
|
||||
}
|
||||
this.plugin.uppy.log('Adding remote file')
|
||||
this.plugin.uppy.addFile(tagFile)
|
||||
this.plugin.uppy.addFile(tagFile).catch(() => {
|
||||
// Ignore
|
||||
})
|
||||
if (!isCheckbox) {
|
||||
this.donePicking()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ module.exports = class Webcam extends Plugin {
|
|||
})
|
||||
return this.getVideo()
|
||||
})
|
||||
.then(this.uppy.addFile)
|
||||
.then((file) => this.uppy.addFile(file))
|
||||
.then(() => {
|
||||
this.recordingChunks = null
|
||||
this.recorder = null
|
||||
|
|
@ -233,9 +233,11 @@ module.exports = class Webcam extends Plugin {
|
|||
return this.getImage()
|
||||
}).then((tagFile) => {
|
||||
this.captureInProgress = false
|
||||
this.uppy.addFile(tagFile)
|
||||
const dashboard = this.uppy.getPlugin('Dashboard')
|
||||
if (dashboard) dashboard.hideAllPanels()
|
||||
return this.uppy.addFile(tagFile).catch(() => {
|
||||
// Ignore
|
||||
})
|
||||
}, (error) => {
|
||||
this.captureInProgress = false
|
||||
throw error
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue