mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 15:50:32 +00:00
fix(nuxt3): only warn within error handling routine (#3394)
This commit is contained in:
parent
e45a780714
commit
2b3dbed594
@ -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))
|
const route: Route = reactive(getRouteFromPath(process.client ? window.location.href : nuxtApp.ssrContext.url))
|
||||||
async function handleNavigation (url: string, replace?: boolean): Promise<void> {
|
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 {
|
try {
|
||||||
// Resolve route
|
// Resolve route
|
||||||
const to = getRouteFromPath(url)
|
const to = getRouteFromPath(url)
|
||||||
@ -131,6 +128,9 @@ export default defineNuxtPlugin<{ route: Route, router: Router }>((nuxtApp) => {
|
|||||||
await middleware(to, route)
|
await middleware(to, route)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} 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) {
|
for (const handler of hooks.error) {
|
||||||
await handler(err)
|
await handler(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user