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
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
16 additions and
10 deletions
-
app/server/static/js/upload.js
|
|
@ -33,14 +33,24 @@ const vm = new Vue({ // eslint-disable-line no-unused-vars |
|
|
|
}) |
|
|
|
.catch((error) => { |
|
|
|
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() { |
|
|
|
const headers = {}; |
|
|
|
if (this.format === 'csv') { |
|
|
@ -66,11 +76,7 @@ const vm = new Vue({ // eslint-disable-line no-unused-vars |
|
|
|
document.body.appendChild(link); |
|
|
|
link.click(); |
|
|
|
}).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); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|