Skip to content

Commit b854a20

Browse files
committed
feat(errors): NavigationDuplicated name for backwards compatibility
1 parent 81f188e commit b854a20

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/history/abstract.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import type Router from '../index'
44
import { History } from './base'
55
import { isRouterError } from '../util/warn'
6-
import { NavigationFailureType } from './errors'
6+
import { NavigationFailureType } from '../util/errors'
77

88
export class AbstractHistory extends History {
99
index: number

src/history/base.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { _Vue } from '../install'
44
import type Router from '../index'
55
import { inBrowser } from '../util/dom'
66
import { runQueue } from '../util/async'
7-
import { warn, isError, isRouterError } from '../util/warn'
7+
import { warn } from '../util/warn'
88
import { START, isSameRoute } from '../util/route'
99
import {
1010
flatten,
@@ -16,8 +16,10 @@ import {
1616
createNavigationCancelledError,
1717
createNavigationRedirectedError,
1818
createNavigationAbortedError,
19+
isError,
20+
isRouterError,
1921
NavigationFailureType
20-
} from './errors'
22+
} from '../util/errors'
2123

2224
export class History {
2325
router: Router

src/history/errors.js src/util/errors.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ export function createNavigationRedirectedError (from, to) {
1717
}
1818

1919
export function createNavigationDuplicatedError (from, to) {
20-
return createRouterError(
20+
const error = createRouterError(
2121
from,
2222
to,
2323
NavigationFailureType.duplicated,
2424
`Avoided redundant navigation to current location: "${from.fullPath}".`
2525
)
26+
// backwards compatible with the first introduction of Errors
27+
error.name = 'NavigationDuplicated'
28+
return error
2629
}
2730

2831
export function createNavigationCancelledError (from, to) {

0 commit comments

Comments
 (0)