From 35d6867f9e219b19f236b03bb665fde1a5da8002 Mon Sep 17 00:00:00 2001 From: Evgeniya Vashkevich Date: Wed, 9 Oct 2024 11:43:17 -0700 Subject: [PATCH] Example of what needs to be done --- shell/initialize/App.vue | 3 +++ shell/initialize/entry-helpers.js | 9 +++++---- shell/initialize/entry.js | 18 ++++++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/shell/initialize/App.vue b/shell/initialize/App.vue index 2d2797f68c5..a49e8c7e992 100644 --- a/shell/initialize/App.vue +++ b/shell/initialize/App.vue @@ -48,6 +48,9 @@ export default { }, methods: { + handleError(error) { + window.$globalApp.$store.dispatch('loadingError', new Error(error), true); + }, refreshOnlineStatus() { if (typeof window.navigator.onLine === 'undefined') { // If the browser doesn't support connection status reports diff --git a/shell/initialize/entry-helpers.js b/shell/initialize/entry-helpers.js index c0f19721d09..ff68e795542 100644 --- a/shell/initialize/entry-helpers.js +++ b/shell/initialize/entry-helpers.js @@ -3,9 +3,7 @@ * @param {*} vueApp Vue instance */ export const loadDebugger = (vueApp) => { - const debug = process.env.dev; - - if (debug) { + const defaultErrorHandler = vueApp.config.errorHandler; vueApp.config.errorHandler = async(err, vm, info, ...rest) => { @@ -35,6 +33,10 @@ export const loadDebugger = (vueApp) => { return handled; } + if (vm?._component?.methods?.handleError) { + vm._component.methods.handleError(err); + } + // Log to console if (process.env.NODE_ENV !== 'production') { console.error(err); // eslint-disable-line no-console @@ -42,7 +44,6 @@ export const loadDebugger = (vueApp) => { console.error(err.message || err); // eslint-disable-line no-console } }; - } }; /** diff --git a/shell/initialize/entry.js b/shell/initialize/entry.js index d8cf2210888..e411761728c 100644 --- a/shell/initialize/entry.js +++ b/shell/initialize/entry.js @@ -25,9 +25,19 @@ installPlugins(vueApp); if (!global.fetch) { global.fetch = fetch; } - -loadDebugger(vueApp); -const errorHandler = vueApp.config.errorHandler || console.error; // eslint-disable-line no-console +const debug = process.env.dev; +if(debug){ + loadDebugger(vueApp); +} else { + //Need to add some error handler for production + vueApp.config.errorHandler = async(err, vm, info, ...rest) => { + if (vm?._component?.methods?.handleError) { + vm._component.methods.handleError(err); + } + } +} // Create and mount App -extendApp(vueApp).then((appPartials) => mountApp(appPartials, vueApp)).catch(errorHandler); // eslint-disable-line no-undef +extendApp(vueApp).then((appPartials) => mountApp(appPartials, vueApp)).catch((err) => { + return vueApp.config.errorHandler ? vueApp.config.errorHandler(err, vueApp) : console.error(err); + }); // eslint-disable-line no-undef