@@ -82,7 +82,7 @@ export class History {
82
82
confirmTransition ( route : Route , onComplete : Function , onAbort ? : Function ) {
83
83
const current = this . current
84
84
const abort = err => {
85
- if ( err instanceof Error ) {
85
+ if ( isError ( err ) ) {
86
86
if ( this . errorCbs . length ) {
87
87
this . errorCbs . forEach ( cb => { cb ( err ) } )
88
88
} else {
@@ -127,7 +127,7 @@ export class History {
127
127
}
128
128
try {
129
129
hook ( route , current , ( to : any ) => {
130
- if ( to === false || to instanceof Error ) {
130
+ if ( to === false || isError ( to ) ) {
131
131
// next(false) -> abort navigation, ensure current URL
132
132
this . ensureURL ( true )
133
133
abort ( to )
@@ -352,7 +352,7 @@ function resolveAsyncComponents (matched: Array<RouteRecord>): Function {
352
352
const msg = `Failed to resolve async component ${ key } : ${ reason } `
353
353
process . env . NODE_ENV !== 'production' && warn ( false , msg )
354
354
if ( ! error ) {
355
- error = reason instanceof Error
355
+ error = isError ( reason )
356
356
? reason
357
357
: new Error ( msg )
358
358
next ( error )
@@ -412,3 +412,7 @@ function once (fn) {
412
412
return fn . apply ( this , arguments )
413
413
}
414
414
}
415
+
416
+ function isError ( err ) {
417
+ return Object . prototype . toString . call ( err ) . indexOf ( 'Error' ) > - 1
418
+ }
0 commit comments