Browse Source

Merge pull request #157 from CatalystCode/bugfix/show-error-on-data-import

Bugfix/Correctly display dataset upload errors
pull/158/head
Hiroki Nakayama 6 years ago
committed by GitHub
parent
commit
f0bf6532d8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 10 deletions
  1. 26
      app/server/static/js/upload.js

26
app/server/static/js/upload.js

@ -33,14 +33,24 @@ const vm = new Vue({ // eslint-disable-line no-unused-vars
}) })
.catch((error) => { .catch((error) => {
this.isLoading = false; this.isLoading = false;
if ('detail' in error.response.data) {
this.messages.push(error.response.data.detail);
} else if ('text' in error.response.data) {
this.messages = error.response.data.text;
}
this.handleError(error);
}); });
}, },
handleError(error) {
const problems = Array.isArray(error.response.data)
? error.response.data
: [error.response.data];
problems.forEach((problem) => {
if ('detail' in problem) {
this.messages.push(problem.detail);
} else if ('text' in problem) {
this.messages = problem.text;
}
});
},
download() { download() {
const headers = {}; const headers = {};
if (this.format === 'csv') { if (this.format === 'csv') {
@ -66,11 +76,7 @@ const vm = new Vue({ // eslint-disable-line no-unused-vars
document.body.appendChild(link); document.body.appendChild(link);
link.click(); link.click();
}).catch((error) => { }).catch((error) => {
if ('detail' in error.response.data) {
this.messages.push(error.response.data.detail);
} else if ('text' in error.response.data) {
this.messages = error.response.data.text;
}
this.handleError(error);
}); });
}, },
}, },

Loading…
Cancel
Save