This commit is contained in:
2020-06-12 18:53:48 +00:00
parent c81b55c000
commit e6f3d324e2
2 changed files with 66 additions and 15 deletions

View File

@@ -57,7 +57,11 @@ function handleError(action, error, route, reject) {
window.$gz.translation.get("ErrorUserNotAuthorized")
);
router.push(window.$gz.store.state.homePage);
return reject("[ErrorUserNotAuthorized]");
if (reject) {
return reject("[ErrorUserNotAuthorized]");
} else {
throw "[ErrorUserNotAuthorized]";
}
}
//Handle 401 not authenticated
@@ -72,7 +76,11 @@ function handleError(action, error, route, reject) {
);
auth.logout();
router.push("/login");
return reject("[ErrorUserNotAuthenticated]");
if (reject) {
return reject("[ErrorUserNotAuthenticated]");
} else {
throw "[ErrorUserNotAuthenticated]";
}
}
//is it a network error?
@@ -96,7 +104,12 @@ function handleError(action, error, route, reject) {
window.$gz.eventBus.$emit("notify-error", msg);
//note: using translation key in square brackets
return reject(msg);
if (reject) {
return reject(msg);
} else {
throw msg;
}
//throw "Error: unable to contact server";
}
}
@@ -460,7 +473,7 @@ export default {
r = await that.extractBodyEx(r);
return r;
} catch (error) {
handleError("UPSERT", error, route, reject);
handleError("UPSERT", error, route);
}
},
upsert(route, data) {