diff --git a/__tests__/lazyLoading.spec.ts b/__tests__/lazyLoading.spec.ts index 9c95a33a5..e50d8fb52 100644 --- a/__tests__/lazyLoading.spec.ts +++ b/__tests__/lazyLoading.spec.ts @@ -265,6 +265,7 @@ describe('Lazy Loading', () => { expect(spy).toHaveBeenCalled() expect(spy).toHaveBeenLastCalledWith(error) + expect('uncaught error').toHaveBeenWarned() expect(router.currentRoute.value).toMatchObject({ path: '/', @@ -284,6 +285,7 @@ describe('Lazy Loading', () => { await router.push('/foo').catch(spy) expect(spy).toHaveBeenCalled() + expect('uncaught error').toHaveBeenWarned() expect(router.currentRoute.value).toMatchObject({ path: '/', @@ -312,6 +314,7 @@ describe('Lazy Loading', () => { await router.push('/foo').catch(spy) expect(spy).toHaveBeenCalledWith(error) + expect('uncaught error').toHaveBeenWarned() expect(router.currentRoute.value).toMatchObject({ path: '/', diff --git a/src/router.ts b/src/router.ts index 1825a3e05..9393ddcca 100644 --- a/src/router.ts +++ b/src/router.ts @@ -1015,9 +1015,17 @@ export function createRouter(options: RouterOptions): Router { * @param error - error to throw * @returns the error as a rejected promise */ - function triggerError(error: any) { + function triggerError(error: any): Promise { markAsReady(error) - errorHandlers.list().forEach(handler => handler(error)) + const list = errorHandlers.list() + if (list.length) { + list.forEach(handler => handler(error)) + } else { + if (__DEV__) { + warn('uncaught error during route navigation:') + } + console.error(error) + } return Promise.reject(error) }