Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
fix: error handling improved by passing error data
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsasharegan committed Feb 9, 2018
1 parent d5a491d commit b042e63
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
20 changes: 10 additions & 10 deletions src/components/VueTransmit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -742,30 +742,30 @@ 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;
}
});
},
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();
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit b042e63

Please sign in to comment.