Skip to content

Commit 852413d

Browse files
committed
use better error check (possible multi-context usage in bundleRenderer)
1 parent d456302 commit 852413d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/history/base.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class History {
8282
confirmTransition (route: Route, onComplete: Function, onAbort?: Function) {
8383
const current = this.current
8484
const abort = err => {
85-
if (err instanceof Error) {
85+
if (isError(err)) {
8686
if (this.errorCbs.length) {
8787
this.errorCbs.forEach(cb => { cb(err) })
8888
} else {
@@ -127,7 +127,7 @@ export class History {
127127
}
128128
try {
129129
hook(route, current, (to: any) => {
130-
if (to === false || to instanceof Error) {
130+
if (to === false || isError(to)) {
131131
// next(false) -> abort navigation, ensure current URL
132132
this.ensureURL(true)
133133
abort(to)
@@ -352,7 +352,7 @@ function resolveAsyncComponents (matched: Array<RouteRecord>): Function {
352352
const msg = `Failed to resolve async component ${key}: ${reason}`
353353
process.env.NODE_ENV !== 'production' && warn(false, msg)
354354
if (!error) {
355-
error = reason instanceof Error
355+
error = isError(reason)
356356
? reason
357357
: new Error(msg)
358358
next(error)
@@ -412,3 +412,7 @@ function once (fn) {
412412
return fn.apply(this, arguments)
413413
}
414414
}
415+
416+
function isError (err) {
417+
return Object.prototype.toString.call(err).indexOf('Error') > -1
418+
}

0 commit comments

Comments
 (0)