changeset 4259:0b90c34fa378

Profiles: improve catching errors
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 26 Aug 2019 15:33:11 +0200
parents 57c38087fe18
children 5b31d1f6aa90
files client/src/components/fairway/Profiles.vue
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/fairway/Profiles.vue	Mon Aug 26 12:49:59 2019 +0200
+++ b/client/src/components/fairway/Profiles.vue	Mon Aug 26 15:33:11 2019 +0200
@@ -498,10 +498,17 @@
         }
       )
         .catch(error => {
-          const { status, data } = error.response;
+          let status, data, message;
+          if (error.response) {
+            status = error.response.status;
+            data = error.response.data;
+            message = `${status}: ${data.message || data}`;
+          } else {
+            message = error;
+          }
           displayError({
             title: this.$gettext("Backend Error"),
-            message: `${status}: ${data.message || data}`
+            message: message
           });
         })
         .finally(() => {