Skip to content

Commit 321cec8

Browse files
committed
feat(errors): NavigationDuplicated name for backwards compatibility
1 parent 3889453 commit 321cec8

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
createNavigationCancelledError,
1717
createNavigationRedirectedError,
1818
createNavigationAbortedError
19-
} from './errors'
19+
} from '../util/errors'
2020

2121
export class History {
2222
router: Router

src/history/errors.js renamed to 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)