This commit is contained in:
2022-03-02 23:02:40 +00:00
parent 7d714f2cea
commit 734975562f
2 changed files with 20 additions and 4 deletions

View File

@@ -121,10 +121,20 @@ export default {
return Promise.resolve(response);
}
},
statusEx(response) {
statusEx(response, isLogin = false) {
//Handle expected api errors
if (response.status == 401) {
throw new Error("LT:ErrorUserNotAuthenticated");
if (!isLogin) {
throw new Error("LT:ErrorUserNotAuthenticated");
} else {
if (
response.statusText.includes("License agreement consent required")
) {
throw new Error(response.statusText);
} else {
throw new Error("LT:ErrorUserNotAuthenticated"); //bad login or password
}
}
}
if (response.status == 403) {
@@ -455,7 +465,7 @@ export default {
}
let r = await fetch(that.APIUrl(route), fetchOptions);
that.statusEx(r);
that.statusEx(r, isLogin);
r = await that.extractBodyEx(r);
return r;
} catch (error) {