case 4489
This commit is contained in:
@@ -83,6 +83,7 @@ function handleError(action, error, route) {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
status(response) {
|
status(response) {
|
||||||
|
//############ THIS IS DEPRECATED IN FAVOR OF STATUSEX BELOW ##################
|
||||||
//Handle expected api errors
|
//Handle expected api errors
|
||||||
if (response.status == 401) {
|
if (response.status == 401) {
|
||||||
throw new Error("LT:ErrorUserNotAuthenticated");
|
throw new Error("LT:ErrorUserNotAuthenticated");
|
||||||
@@ -121,7 +122,7 @@ export default {
|
|||||||
return Promise.resolve(response);
|
return Promise.resolve(response);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
statusEx(response) {
|
statusEx(response, data) {
|
||||||
//Handle expected api errors
|
//Handle expected api errors
|
||||||
if (response.status == 401) {
|
if (response.status == 401) {
|
||||||
throw new Error("LT:ErrorUserNotAuthenticated");
|
throw new Error("LT:ErrorUserNotAuthenticated");
|
||||||
@@ -143,6 +144,23 @@ export default {
|
|||||||
throw new Error("Method Not Allowed (route issue?) " + response.url);
|
throw new Error("Method Not Allowed (route issue?) " + response.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Bad request error need to see the request in the log for troubleshooting more esoteric errors remotely
|
||||||
|
//case 4485
|
||||||
|
if (response.status == 400) {
|
||||||
|
window.$gz.store.commit(
|
||||||
|
"logItem",
|
||||||
|
"API error: status=" +
|
||||||
|
response.status +
|
||||||
|
", statusText=" +
|
||||||
|
response.statusText +
|
||||||
|
", url=" +
|
||||||
|
response.url +
|
||||||
|
", request data=" +
|
||||||
|
JSON.stringify(data)
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (response.status >= 200 && response.status < 300) {
|
if (response.status >= 200 && response.status < 300) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -465,7 +483,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let r = await fetch(that.APIUrl(route), fetchOptions);
|
let r = await fetch(that.APIUrl(route), fetchOptions);
|
||||||
that.statusEx(r);
|
that.statusEx(r, data);
|
||||||
r = await that.extractBodyEx(r);
|
r = await that.extractBodyEx(r);
|
||||||
return r;
|
return r;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -501,7 +519,7 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const that = this;
|
const that = this;
|
||||||
let r = await fetch(that.APIUrl(route), that.fetchPutOptions(data));
|
let r = await fetch(that.APIUrl(route), that.fetchPutOptions(data));
|
||||||
that.statusEx(r);
|
that.statusEx(r, data);
|
||||||
r = await that.extractBodyEx(r);
|
r = await that.extractBodyEx(r);
|
||||||
return r;
|
return r;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -515,7 +533,7 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const that = this;
|
const that = this;
|
||||||
let r = await fetch(that.APIUrl(route), that.fetchPostOptions(data));
|
let r = await fetch(that.APIUrl(route), that.fetchPostOptions(data));
|
||||||
that.statusEx(r);
|
that.statusEx(r, data);
|
||||||
r = await that.extractBodyEx(r);
|
r = await that.extractBodyEx(r);
|
||||||
return r;
|
return r;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user