This commit is contained in:
@@ -28,6 +28,7 @@ ISSUE: need to display multiple types of messages, best way to do that??
|
|||||||
- Application errors
|
- Application errors
|
||||||
- Make them show with the server error box, rejig it as a generic error box
|
- Make them show with the server error box, rejig it as a generic error box
|
||||||
- App errors don't need to survive page reload or api call, if they are that serious then they would be notifications instead
|
- App errors don't need to survive page reload or api call, if they are that serious then they would be notifications instead
|
||||||
|
- clearing server errors does not necessarily clear message box errors?
|
||||||
- Notifications, stuff that you want to know is there and can go and look at but isn't urgent enough to put in the users face
|
- Notifications, stuff that you want to know is there and can go and look at but isn't urgent enough to put in the users face
|
||||||
- Used for notification system, non-urgent system messages, direct messages from users etc, anything that isn't immediately important
|
- Used for notification system, non-urgent system messages, direct messages from users etc, anything that isn't immediately important
|
||||||
- This seems like an application wide thing so maybe a bell icon that takes to another area of the program, or opens a div at the top or bottom of the page??
|
- This seems like an application wide thing so maybe a bell icon that takes to another area of the program, or opens a div at the top or bottom of the page??
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ var devModeShowErrors = false;
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Log and optionally display errors
|
// Localize, Log and optionally display errors
|
||||||
//
|
// return localized message in case caller needs it
|
||||||
function dealWithError(msg, displayToUser) {
|
function dealWithError(msg, form) {
|
||||||
msg = locale.translateString(msg);
|
msg = locale.translateString(msg);
|
||||||
//In some cases the error may not be localizable, if this is not a debug run then it should show without the ?? that localizing puts in keys not found
|
//In some cases the error may not be localizable, if this is not a debug run then it should show without the ?? that localizing puts in keys not found
|
||||||
//so it's not as wierd looking to the user
|
//so it's not as wierd looking to the user
|
||||||
@@ -16,9 +16,22 @@ function dealWithError(msg, displayToUser) {
|
|||||||
msg = msg.replace("??", "");
|
msg = msg.replace("??", "");
|
||||||
}
|
}
|
||||||
store.commit("logItem", msg);
|
store.commit("logItem", msg);
|
||||||
if (displayToUser || devModeShowErrors) {
|
if (devModeShowErrors) {
|
||||||
alert("~" + msg);
|
alert("~" + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If a form instance was provided (vue instance)
|
||||||
|
//then put the error into it
|
||||||
|
if (form) {
|
||||||
|
if (form.$gzdevmode()) {
|
||||||
|
//make sure appError is defined on data
|
||||||
|
if (!form.$_.has(form, "appError")) {
|
||||||
|
throw "DEV ERROR errorHandler::dealWithError -> appError seems to be missing from form's vue data object";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
form.appError = msg;
|
||||||
|
form.$gzv.SetErrorBoxErrors(form);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export default {
|
export default {
|
||||||
developmentModeShowErrorsImmediately(showErrorsImmediately) {
|
developmentModeShowErrorsImmediately(showErrorsImmediately) {
|
||||||
@@ -63,12 +76,16 @@ export default {
|
|||||||
}
|
}
|
||||||
dealWithError(msg);
|
dealWithError(msg);
|
||||||
},
|
},
|
||||||
handleFormError(err, displayToUser) {
|
/////////////////////////////////////////////////
|
||||||
//called inside forms when things go wrong but are handled
|
// Localize, log and return error
|
||||||
|
//
|
||||||
|
handleFormError(err, form) {
|
||||||
|
//called inside forms when things go wrong
|
||||||
|
//returns the localized message in case the form wants to display it as well
|
||||||
if (err instanceof Error && err.message) {
|
if (err instanceof Error && err.message) {
|
||||||
dealWithError(err.message, displayToUser);
|
dealWithError(err.message, form);
|
||||||
} else {
|
} else {
|
||||||
dealWithError(err.toString(), displayToUser);
|
dealWithError(err.toString(), form);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ export default {
|
|||||||
// SERVER ERRORS
|
// SERVER ERRORS
|
||||||
// Process and return server errors if any for form and field specified
|
// Process and return server errors if any for form and field specified
|
||||||
ServerErrors(v, ref) {
|
ServerErrors(v, ref) {
|
||||||
//CHECK PREREQUISITES IN DEV MODE TO ENSURE FORM ISN"T MISSING NEEDE DATA ATTRIBUTES ETC
|
//CHECK PREREQUISITES IN DEV MODE TO ENSURE FORM ISN"T MISSING NEEDED DATA ATTRIBUTES ETC
|
||||||
if (v.$gzdevmode()) {
|
if (v.$gzdevmode()) {
|
||||||
//make sure serverErrors is defined on data
|
//make sure serverErrors is defined on data
|
||||||
if (!v.$_.has(v, "serverError")) {
|
if (!v.$_.has(v, "serverError")) {
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ export default {
|
|||||||
obj: {},
|
obj: {},
|
||||||
serverError: {},
|
serverError: {},
|
||||||
errorBoxMessage: null,
|
errorBoxMessage: null,
|
||||||
appError:null,
|
appError: null,
|
||||||
formReady: false
|
formReady: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -187,14 +187,19 @@ export default {
|
|||||||
getDataFromApi() {
|
getDataFromApi() {
|
||||||
var url = "Widget/" + this.$route.params.id;
|
var url = "Widget/" + this.$route.params.id;
|
||||||
var that = this;
|
var that = this;
|
||||||
this.$gzv.DeleteAllErrorBoxErrors(this);
|
this.$gzv.DeleteAllErrorBoxErrors(this);
|
||||||
this.$gzapi
|
this.$gzapi
|
||||||
.get(url)
|
.get(url)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.obj = res.data;
|
if (res.error) {
|
||||||
|
that.serverError = res.error;
|
||||||
|
that.$gzv.SetErrorBoxErrors(that);
|
||||||
|
} else {
|
||||||
|
that.obj = res.data;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
that.$gzHandleFormError(error, true);
|
that.$gzHandleFormError(error, that);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
@@ -225,7 +230,7 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
that.$gzHandleFormError(error, true);
|
that.$gzHandleFormError(error, that);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} //end of submit()
|
} //end of submit()
|
||||||
|
|||||||
Reference in New Issue
Block a user