diff --git a/src/App.vue b/src/App.vue index 31fb663c3..bbaf78622 100644 --- a/src/App.vue +++ b/src/App.vue @@ -12,6 +12,7 @@ import { handleAnyComponentFocus } from "@/helpers/button-question-focus-helper"; import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue"; import { showFmgLoadingModal } from "@/helpers/loading-modal-helper"; + export default { name: "app", setup() { @@ -33,6 +34,24 @@ export default { loadingModal, }, }; + +// Add a global Javascript exception handler for logging exceptions, this handler will log when there is an uncaught exception +window.onerror = (msg, url, line, col, error) => { + // Log the windows error + // Note that col & error are new to the HTML 5 spec and may not be + // supported in every browser. It worked for me in Chrome. + global.$logger.logError(msg, { + url: url, + line: line, + column: col ?? "", + error: error ?? "", + }); + + // If you return true, then error alerts (like in older versions of + // Internet Explorer) will be suppressed. + var suppressErrorAlert = true; + return suppressErrorAlert; +};