From 4e11e43755f8edea8a89cc3d11fc629e74ba8e96 Mon Sep 17 00:00:00 2001 From: Ifedapo Olarewaju Date: Mon, 11 Dec 2017 01:06:18 +0100 Subject: [PATCH] fix: handle remote upload error events #446 --- src/plugins/Tus.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/Tus.js b/src/plugins/Tus.js index bfff6d937..2a8631c16 100644 --- a/src/plugins/Tus.js +++ b/src/plugins/Tus.js @@ -232,7 +232,7 @@ module.exports = class Tus extends Plugin { })) }) .then((res) => { - if (res.status < 200 && res.status > 300) { + if (res.status < 200 || res.status > 300) { return reject(res.statusText) } @@ -289,6 +289,10 @@ module.exports = class Tus extends Plugin { socket.on('progress', (progressData) => emitSocketProgress(this, progressData, file)) + socket.on('error', (errData) => { + this.core.emitter.emit('core:upload-error', file.id, new Error(errData.error)) + }) + socket.on('success', (data) => { this.core.emitter.emit('core:upload-success', file.id, data, data.url) this.resetUploaderReferences(file.id)