Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(nuxt3): only warn within error handling routine (#3394)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Feb 25, 2022
1 parent e45a780 commit 2b3dbed
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/nuxt3/src/app/plugins/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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)
Expand All @@ -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)
}
Expand Down

0 comments on commit 2b3dbed

Please sign in to comment.