mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Catch router events errors and print them. (#2663)
This commit is contained in:
parent
cf130c70f0
commit
cc9b1d6ce0
|
@ -42,7 +42,12 @@ routerEvents.forEach((event) => {
|
|||
SingletonRouter.router.events.on(event, (...args) => {
|
||||
const eventField = `on${event.charAt(0).toUpperCase()}${event.substring(1)}`
|
||||
if (SingletonRouter[eventField]) {
|
||||
try {
|
||||
SingletonRouter[eventField](...args)
|
||||
} catch (err) {
|
||||
console.error(`Error when running the Router event: ${eventField}`)
|
||||
console.error(`${err.message}\n${err.stack}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue