From 2b3dbed594122607720be349475a296fa410b3b6 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 25 Feb 2022 16:33:27 +0000 Subject: [PATCH] fix(nuxt3): only warn within error handling routine (#3394) --- packages/nuxt3/src/app/plugins/router.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nuxt3/src/app/plugins/router.ts b/packages/nuxt3/src/app/plugins/router.ts index ced79a5392..c64a4ff8a6 100644 --- a/packages/nuxt3/src/app/plugins/router.ts +++ b/packages/nuxt3/src/app/plugins/router.ts @@ -103,9 +103,6 @@ export default defineNuxtPlugin<{ route: Route, router: Router }>((nuxtApp) => { const route: Route = reactive(getRouteFromPath(process.client ? window.location.href : nuxtApp.ssrContext.url)) async function handleNavigation (url: string, replace?: boolean): Promise { - if (process.dev && process.client && !hooks.error.length) { - console.warn('No error handlers registered to handle middleware errors. You can register an error handler with `router.onError()`') - } try { // Resolve route const to = getRouteFromPath(url) @@ -131,6 +128,9 @@ export default defineNuxtPlugin<{ route: Route, router: Router }>((nuxtApp) => { await middleware(to, route) } } catch (err) { + if (process.dev && !hooks.error.length) { + console.warn('No error handlers registered to handle middleware errors. You can register an error handler with `router.onError()`', err) + } for (const handler of hooks.error) { await handler(err) }