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 @@
- {{ icon }}
- {{ message }}
+ {{ info.icon }}
+ {{ $t(info.message) }}
@@ -13,6 +13,10 @@
import HeaderBar from "@/components/header/HeaderBar";
const errors = {
+ 0: {
+ icon: "cloud_off",
+ message: "errors.connection",
+ },
403: {
icon: "error",
message: "errors.forbidden",
@@ -33,11 +37,17 @@ export default {
HeaderBar,
},
props: ["errorCode", "showHeader"],
- data: function () {
- return {
- icon: errors[this.errorCode].icon,
- message: this.$t(errors[this.errorCode].message),
- };
+ computed: {
+ code() {
+ return this.errorCode === "0" ||
+ this.errorCode === "404" ||
+ this.errorCode === "403"
+ ? parseInt(this.errorCode)
+ : 500;
+ },
+ info() {
+ return errors[this.code];
+ },
},
};
diff --git a/frontend/src/views/Files.vue b/frontend/src/views/Files.vue
index 02d73c61..3ae407c2 100644
--- a/frontend/src/views/Files.vue
+++ b/frontend/src/views/Files.vue
@@ -4,7 +4,7 @@
-
+
@@ -67,11 +67,6 @@ export default {
return "preview";
}
},
- errorCode() {
- return this.error.message === "404" || this.error.message === "403"
- ? parseInt(this.error.message)
- : 500;
- },
},
created() {
this.fetchData();
diff --git a/frontend/src/views/Share.vue b/frontend/src/views/Share.vue
index cc370cfe..790bf64d 100644
--- a/frontend/src/views/Share.vue
+++ b/frontend/src/views/Share.vue
@@ -60,7 +60,7 @@
-
+
@@ -230,11 +230,6 @@ export default {
humanTime: function () {
return moment(this.req.modified).fromNow();
},
- errorCode() {
- return this.error.message === "404" || this.error.message === "403"
- ? parseInt(this.error.message)
- : 500;
- },
},
methods: {
...mapMutations(["resetSelected", "updateRequest", "setLoading"]),