diff --git a/jest.config.js b/jest.config.js index 6c0addf5f..a8063f324 100644 --- a/jest.config.js +++ b/jest.config.js @@ -15,6 +15,7 @@ module.exports = { "!src/main.js", "!src/constants/*.js", "!src/router/**/*.js", + "src/router/methods/error.js", // Re-include after the exclusion above (Jest applies later positive globs as overrides). "!src/helpers/unit-test-helper.js", "!src/helpers/logger.js", "!src/layouts/vehicle-damage/windshield-options/windshield-options.vue", diff --git a/src/App.vue b/src/App.vue index cae31dd24..2b9bc5a33 100644 --- a/src/App.vue +++ b/src/App.vue @@ -64,6 +64,16 @@ window.onerror = (msg, url, line, col, error) => { var suppressErrorAlert = true; return suppressErrorAlert; }; + +// Log Promise rejections that are never handled (.catch / await try/catch), e.g. fire-and-forget async. +window.addEventListener("unhandledrejection", (event) => { + const reason = event.reason; + const message = reason instanceof Error ? reason.message : String(reason); + global.$logger.logError(`unhandledrejection: ${message}`, { + stack: reason instanceof Error ? reason.stack : undefined, + reason: reason instanceof Error ? undefined : reason, + }); +});