Skip to content

Commit

Permalink
fix(upload-core): check xhr error message from header
Browse files Browse the repository at this point in the history
  • Loading branch information
Christie Baker authored and Christie Baker committed Apr 24, 2018
1 parent 8f309df commit 1609d58
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions packages/upload-core/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class Upload {
this.bytesSent = 0;
this.bytesScanned = 0;
this.errorMessage = null;
this.errorCode = null;
this.status = 'pending';
this.timeoutID = undefined;
this.error = null;
Expand Down Expand Up @@ -324,18 +323,17 @@ class Upload {

parseErrorMessage(message, err) {
if (err) {
const originalErrorMessage = err.message;
let temp = originalErrorMessage.match(/response\Wcode:\W([0-9]*)/);
if (temp && temp.length === 2) {
[, this.errorCode] = temp;
}
temp = originalErrorMessage.match(/response\Wtext:\W(.*)\)/);
if (temp && temp.length === 2) {
[, this.errorMessage] = temp;
let msg = err.originalRequest.getResponseHeader('Upload-Message');
if (!msg) {
const temp = err.message.match(/response\Wtext:\W(.*)\)/);
if (temp && temp.length === 2) {
[, msg] = temp;
}
}
if (!this.errorMessage && this.errorMessage !== '') {
this.errorMessage = message;
if (!msg) {
msg = message;
}
this.errorMessage = msg;
} else {
this.errorMessage = message;
}
Expand Down

0 comments on commit 1609d58

Please sign in to comment.