From 5e6f14b5dcb9c5efdf526f1346e09c2d0b2f6974 Mon Sep 17 00:00:00 2001
From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com>
Date: Fri, 16 Apr 2021 14:01:10 +0000
Subject: [PATCH] feat: message for connection error
---
frontend/src/api/utils.js | 19 ++++++++++++-------
frontend/src/i18n/en.json | 3 ++-
frontend/src/views/Errors.vue | 24 +++++++++++++++++-------
frontend/src/views/Files.vue | 7 +------
frontend/src/views/Share.vue | 7 +------
5 files changed, 33 insertions(+), 27 deletions(-)
diff --git a/frontend/src/api/utils.js b/frontend/src/api/utils.js
index ed705d2b..65c6740a 100644
--- a/frontend/src/api/utils.js
+++ b/frontend/src/api/utils.js
@@ -8,13 +8,18 @@ export async function fetchURL(url, opts) {
let { headers, ...rest } = opts;
- const res = await fetch(`${baseURL}${url}`, {
- headers: {
- "X-Auth": store.state.jwt,
- ...headers,
- },
- ...rest,
- });
+ let res;
+ try {
+ res = await fetch(`${baseURL}${url}`, {
+ headers: {
+ "X-Auth": store.state.jwt,
+ ...headers,
+ },
+ ...rest,
+ });
+ } catch (error) {
+ return { status: 0 };
+ }
if (res.headers.get("X-Renew-Token") === "true") {
await renew(store.state.jwt);
diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json
index dced12f3..a9f8a057 100644
--- a/frontend/src/i18n/en.json
+++ b/frontend/src/i18n/en.json
@@ -43,7 +43,8 @@
"errors": {
"forbidden": "You don't have permissions to access this.",
"internal": "Something really went wrong.",
- "notFound": "This location can't be reached."
+ "notFound": "This location can't be reached.",
+ "connection": "The server can't be reached."
},
"files": {
"body": "Body",
diff --git a/frontend/src/views/Errors.vue b/frontend/src/views/Errors.vue
index 5efe83ec..b010906d 100644
--- a/frontend/src/views/Errors.vue
+++ b/frontend/src/views/Errors.vue
@@ -3,8 +3,8 @@