CSR-1855 global error handling

CSR-1855 global error handling
This commit is contained in:
CarlNation 2024-01-09 09:55:30 -05:00
parent 9aa8700eec
commit 285bad0eb1
4 changed files with 35 additions and 0 deletions

View file

@ -4,6 +4,7 @@ const globalEvents = {
},
SubCategories: {
PAGE_NOT_FOUND: "PAGE_NOT_FOUND",
UNKNOWN_ERROR: "UNKNOWN_ERROR",
},
};

View file

@ -72,6 +72,17 @@ export default {
alertEvent.displayAlert = true;
this.globalAlertMessages.push(alertEvent);
}
//Uknown alerts most likely were added by a failed api call in global-methods
const unknownAlertEvent = eventBus.readAndPopEventFromBus(
globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.UNKNOWN_ERROR
);
if (unknownAlertEvent !== undefined) {
unknownAlertEvent.displayAlert = true;
this.globalAlertMessages.push(unknownAlertEvent);
}
},
};
</script>

View file

@ -61,6 +61,7 @@ export default {
);
}
router.navigateError();
return reject(error.response);
}
);

View file

@ -239,6 +239,10 @@ router.navigateToExternalUrl = (url, optionalQuery = {}) => {
navigateToUrl(url, optionalQuery);
};
router.navigateError = () => {
DisplayPageError();
};
//Use this navigation when you need to call next() explicitly. beforeRouteEnter is a good example.
router.overrideNavigation = (
scenario,
@ -403,6 +407,24 @@ function GoToFunnelStartOn404(next) {
});
}
async function DisplayPageError() {
// Put item on the bus
eventBus.addEventToBus(
globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.UNKNOWN_ERROR,
{
isDismissible: true,
messageCopy: "",
messageHeadline: "We're sorry, something went wrong.",
type: globalEventTypes.Danger,
}
);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE);
location.reload();
}
function isExistingFmgPageName(pageName) {
const names = Object.values(fmgPageValues);