Merge pull request #5026 from betagouv/js-return-true-errors

javascript: make DirectUpload errors return true error objects
This commit is contained in:
Paul Chavard 2020-04-09 13:09:19 +02:00 committed by GitHub
commit b022a26db5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,10 +15,10 @@ export default class Uploader {
this.progressBar.start();
return new Promise((resolve, reject) => {
this.directUpload.create((error, attributes) => {
if (error) {
this.progressBar.error(error);
reject(error);
this.directUpload.create((errorMsg, attributes) => {
if (errorMsg) {
this.progressBar.error(errorMsg);
reject(new Error(errorMsg));
} else {
resolve(attributes.signed_id);
}