Code to improve error message display (prevent repeats, log to console dev errors instead of alert box)

This commit is contained in:
2019-11-13 23:09:34 +00:00
parent 1d3d00c6f5
commit 7148291c20
2 changed files with 28 additions and 2 deletions

View File

@@ -1,14 +1,24 @@
/* xeslint-disable */
var devModeShowErrors = false;
var lastMessageHash = 0;
////////////////////////////////////////////////////////
//
// Localize, Log and optionally display errors
// return localized message in case caller needs it
function dealWithError(msg, vm) {
//debugger;
//Check if this is the same message again as last time to avoid
//repetitive loops of useless messages
var newHash = window.$gz.gzutil.quickHash(msg);
if (newHash == lastMessageHash) {
return;
}
lastMessageHash = newHash;
//localize as necessary
msg = window.$gz.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
//so it's not as weird looking to the user
if (!devModeShowErrors && msg.includes("??")) {
@@ -21,7 +31,6 @@ function dealWithError(msg, vm) {
msg;
// eslint-disable-next-line no-console
console.log(errMsg);
window.$gz.eventBus.$emit("notify-error", "Dev error see log / console");
}