File tree 2 files changed +6
-8
lines changed
2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -78,14 +78,14 @@ export class History {
78
78
onAbort ? : Function
79
79
) {
80
80
let route
81
+ // catch redirect option https://github.com/vuejs/vue-router/issues/3201
81
82
try {
82
83
route = this . router . match ( location , this . current )
83
84
} catch ( e ) {
84
85
this . errorCbs . forEach ( cb => {
85
86
cb ( e )
86
87
} )
87
88
// Exception should still be thrown
88
- // https://github.com/vuejs/vue-router/issues/3201
89
89
throw e
90
90
}
91
91
this . confirmTransition (
Original file line number Diff line number Diff line change @@ -184,14 +184,12 @@ describe('error handling', () => {
184
184
} )
185
185
} )
186
186
187
- it ( 'should trigger onError when an exception is thrown' , done => {
187
+ it ( 'should trigger onError if error is thrown inside redirect option' , done => {
188
+ const error = new Error ( 'foo' )
188
189
const config = [ {
189
190
path : '/oldpath/:part' ,
190
191
redirect : ( to ) => {
191
- if ( to . ooopsmistake . part ) {
192
- return `/newpath/${ to . params . part } `
193
- }
194
- return '/newpath/'
192
+ throw error
195
193
}
196
194
} ]
197
195
@@ -207,8 +205,8 @@ describe('error handling', () => {
207
205
. push ( '/oldpath/test' )
208
206
. catch ( pushCatch )
209
207
. finally ( ( ) => {
210
- expect ( pushCatch ) . toHaveBeenCalled ( )
211
- expect ( onError ) . toHaveBeenCalled ( )
208
+ expect ( pushCatch ) . toHaveBeenCalledWith ( error )
209
+ expect ( onError ) . toHaveBeenCalledWith ( error )
212
210
done ( )
213
211
} )
214
212
} )
You can’t perform that action at this time.
0 commit comments