From baf1661555eac0a96027177a132ab21c0c7e41d7 Mon Sep 17 00:00:00 2001
From: Sonia Zorba <sonia.zorba@inaf.it>
Date: Fri, 25 Jun 2021 14:47:53 +0200
Subject: [PATCH] Handled upload errors

---
 vospace-ui-frontend/src/store.js | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/vospace-ui-frontend/src/store.js b/vospace-ui-frontend/src/store.js
index ffa8604..051e2a5 100644
--- a/vospace-ui-frontend/src/store.js
+++ b/vospace-ui-frontend/src/store.js
@@ -188,16 +188,24 @@ export default new Vuex.Store({
       for (let file of files) {
         names.push(file.name);
       }
-      client.prepareForUpload(state.path, names)
+      return client.prepareForUpload(state.path, names)
         .then(uploadUrls => {
           let uploads = [];
           for (let i = 0; i < files.length; i++) {
             uploads.push(client.uploadFile(uploadUrls[i], files[i]));
           }
-          Promise.all(uploads).then(() => {
-            // Reload current node when all uploads completed
-            dispatch('setPath', state.path);
-          });
+          Promise.all(uploads)
+            .then(() => {
+              // Reload current node when all uploads completed
+              dispatch('setPath', state.path);
+            })
+            .catch(error => {
+              let message = "Unable to upload file"
+              if (error.response && error.response.data) {
+                message += ": " + error.response.data;
+              }
+              main.showError(message);
+            });
         });
     },
     deleteNodes({ state, dispatch }) {
-- 
GitLab