Skip to content

Commit

Permalink
feat(errors): NavigationDuplicated name for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jul 31, 2020
1 parent 81f188e commit b854a20
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/history/abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type Router from '../index'
import { History } from './base'
import { isRouterError } from '../util/warn'
import { NavigationFailureType } from './errors'
import { NavigationFailureType } from '../util/errors'

export class AbstractHistory extends History {
index: number
Expand Down
6 changes: 4 additions & 2 deletions src/history/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { _Vue } from '../install'
import type Router from '../index'
import { inBrowser } from '../util/dom'
import { runQueue } from '../util/async'
import { warn, isError, isRouterError } from '../util/warn'
import { warn } from '../util/warn'
import { START, isSameRoute } from '../util/route'
import {
flatten,
Expand All @@ -16,8 +16,10 @@ import {
createNavigationCancelledError,
createNavigationRedirectedError,
createNavigationAbortedError,
isError,
isRouterError,
NavigationFailureType
} from './errors'
} from '../util/errors'

export class History {
router: Router
Expand Down
5 changes: 4 additions & 1 deletion src/history/errors.js → src/util/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ export function createNavigationRedirectedError (from, to) {
}

export function createNavigationDuplicatedError (from, to) {
return createRouterError(
const error = createRouterError(
from,
to,
NavigationFailureType.duplicated,
`Avoided redundant navigation to current location: "${from.fullPath}".`
)
// backwards compatible with the first introduction of Errors
error.name = 'NavigationDuplicated'
return error
}

export function createNavigationCancelledError (from, to) {
Expand Down

0 comments on commit b854a20

Please sign in to comment.