This commit is contained in:
@@ -35,6 +35,7 @@ var devShowUnknownError = function(error) {
|
||||
|
||||
export default {
|
||||
status(response) {
|
||||
//Handle expected api errors
|
||||
if (response.status == 401) {
|
||||
//must reject if not authorized
|
||||
return Promise.reject(new Error("401 - NOT AUTHORIZED"));
|
||||
@@ -43,6 +44,7 @@ export default {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return Promise.resolve(response);
|
||||
} else {
|
||||
//log unhandled api error
|
||||
store.commit(
|
||||
"logItem",
|
||||
"API error: status=" +
|
||||
@@ -52,10 +54,7 @@ export default {
|
||||
", url=" +
|
||||
response.url
|
||||
);
|
||||
|
||||
//TODO: If no viable data to return then should reject, otherwise should resolve regardless
|
||||
//Nope because we will never get here if nothing at all was returned so what is this actually doing??
|
||||
|
||||
//let it float up for dealing with by caller(s)
|
||||
return Promise.resolve(response);
|
||||
}
|
||||
},
|
||||
|
||||
21
ayanova/src/api/gzutil.js
Normal file
21
ayanova/src/api/gzutil.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/* Xeslint-disable */
|
||||
|
||||
/////////////////////////////////
|
||||
// General utility library
|
||||
//
|
||||
export default {
|
||||
///////////////////////////////
|
||||
// CLEAN OBJECT
|
||||
// Clear all properties from object without resorting to assigning a new object (o={})
|
||||
// which can be problematic in some cases (IE bugs, watched data items in forms etc)
|
||||
|
||||
RemoveAllPropertiesFromObject(o) {
|
||||
for (var variableKey in o) {
|
||||
if (o.hasOwnProperty(variableKey)) {
|
||||
delete o[variableKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//new functions above here
|
||||
};
|
||||
@@ -485,7 +485,7 @@ Here are all the API level error codes that can be returned by the API server:
|
||||
//If there are no more errors in details then remove the whole thing as it's no longer required
|
||||
if (v.serverError.details && v.serverError.details.length < 1) {
|
||||
if (v.serverError.code == "2200") {
|
||||
this.RemoveAllProperties(v.serverError);
|
||||
v.$gzutil.RemoveAllPropertiesFromObject(v.serverError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user