File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -265,6 +265,7 @@ describe('Lazy Loading', () => {
265
265
266
266
expect ( spy ) . toHaveBeenCalled ( )
267
267
expect ( spy ) . toHaveBeenLastCalledWith ( error )
268
+ expect ( 'uncaught error' ) . toHaveBeenWarned ( )
268
269
269
270
expect ( router . currentRoute . value ) . toMatchObject ( {
270
271
path : '/' ,
@@ -284,6 +285,7 @@ describe('Lazy Loading', () => {
284
285
await router . push ( '/foo' ) . catch ( spy )
285
286
286
287
expect ( spy ) . toHaveBeenCalled ( )
288
+ expect ( 'uncaught error' ) . toHaveBeenWarned ( )
287
289
288
290
expect ( router . currentRoute . value ) . toMatchObject ( {
289
291
path : '/' ,
@@ -312,6 +314,7 @@ describe('Lazy Loading', () => {
312
314
await router . push ( '/foo' ) . catch ( spy )
313
315
314
316
expect ( spy ) . toHaveBeenCalledWith ( error )
317
+ expect ( 'uncaught error' ) . toHaveBeenWarned ( )
315
318
316
319
expect ( router . currentRoute . value ) . toMatchObject ( {
317
320
path : '/' ,
Original file line number Diff line number Diff line change @@ -1015,9 +1015,17 @@ export function createRouter(options: RouterOptions): Router {
1015
1015
* @param error - error to throw
1016
1016
* @returns the error as a rejected promise
1017
1017
*/
1018
- function triggerError ( error : any ) {
1018
+ function triggerError ( error : any ) : Promise < unknown > {
1019
1019
markAsReady ( error )
1020
- errorHandlers . list ( ) . forEach ( handler => handler ( error ) )
1020
+ const list = errorHandlers . list ( )
1021
+ if ( list . length ) {
1022
+ list . forEach ( handler => handler ( error ) )
1023
+ } else {
1024
+ if ( __DEV__ ) {
1025
+ warn ( 'uncaught error during route navigation:' )
1026
+ }
1027
+ console . error ( error )
1028
+ }
1021
1029
return Promise . reject ( error )
1022
1030
}
1023
1031
You can’t perform that action at this time.
0 commit comments