From b042e6367bd7bb20bc5792b2892c9936ed151ae3 Mon Sep 17 00:00:00 2001 From: Alex Regan Date: Fri, 9 Feb 2018 11:00:03 -0700 Subject: [PATCH] fix: error handling improved by passing error data --- package.json | 2 ++ src/components/VueTransmit.vue | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index c5e74e1..6d30539 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,9 @@ "size:min": "cat dist/vue-transmit.esm.js | wc -c", "size:gzip": "gzip -c dist/vue-transmit.esm.js | wc -c", "release:alpha": "standard-version --prerelease alpha", + "postrelease:alpha": "git push --follow-tags origin master && npm publish --tag prerelease", "release:beta": "standard-version --prerelease beta", + "postrelease:beta": "git push --follow-tags origin master && npm publish --tag prerelease", "release": "standard-version", "postrelease": "git push --follow-tags origin master && npm publish" }, diff --git a/src/components/VueTransmit.vue b/src/components/VueTransmit.vue index ab08ab9..96c1ceb 100644 --- a/src/components/VueTransmit.vue +++ b/src/components/VueTransmit.vue @@ -75,7 +75,7 @@ import { import { VTransmitFile } from "../classes/VTransmitFile"; import { VTransmitUploadContext } from "../classes/VTransmitUploadContext"; import { XHRUploadAdapter } from "../upload-adapters/xhr"; -import { UploaderInterface } from "../core/interfaces"; +import { UploaderInterface, UploadReject } from "../core/interfaces"; type FileSystemEntry = WebKitFileEntry | WebKitDirectoryEntry; @@ -742,14 +742,14 @@ export default Vue.extend({ this.transport .uploadFiles(files) .then(response => this.uploadFinished(files, response)) - .catch(err => { + .catch((err: UploadReject) => { switch (err.event) { case Events.Timeout: - this.handleTimeout(files, err.message); + this.handleTimeout(files, err.message, err.data); break; case Events.Error: default: - this.errorProcessing(files, err.message); + this.errorProcessing(files, err.message, err.data); break; } }); @@ -757,15 +757,15 @@ export default Vue.extend({ handleTimeout( files: VTransmitFile[], message: string, - ...args: any[] + data: AnyObject ): void { let f: VTransmitFile; for (f of files) { f.status = UploadStatuses.Timeout; f.endProgress(); - this.$emit(Events.Timeout, f, message, ...args); + this.$emit(Events.Timeout, f, message, data); } - this.$emit(Events.TimeoutMultiple, files, message, ...args); + this.$emit(Events.TimeoutMultiple, files, message, data); if (this.autoProcessQueue) { this.processQueue(); @@ -812,17 +812,17 @@ export default Vue.extend({ errorProcessing( files: VTransmitFile[], message: string, - xhr?: XMLHttpRequest + data: AnyObject = {} ) { for (const file of files) { file.status = UploadStatuses.Error; file.endProgress(); - this.$emit(Events.Error, file, message, xhr); + this.$emit(Events.Error, file, message, data); this.$emit(Events.Complete, file); } if (this.uploadMultiple) { - this.$emit(Events.ErrorMultiple, files, message, xhr); + this.$emit(Events.ErrorMultiple, files, message, data); this.$emit(Events.CompleteMultiple, files); }