Skip to content

Commit

Permalink
feat(errors): add stack trace to NavigationDuplicated
Browse files Browse the repository at this point in the history
Closes #2881
  • Loading branch information
posva committed Aug 21, 2019
1 parent 5141def commit 5ef5d73
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/history/errors.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
export class NavigationDuplicated extends Error {
constructor () {
super('Navigating to current location is not allowed')
constructor (normalizedLocation) {
super()
this.name = this._name = 'NavigationDuplicated'
// passing the message to super() doesn't seem to work in the transpiled version
this.message = `Navigating to current location ("${
normalizedLocation.fullPath
}") is not allowed`
// add a stack property so services like Sentry can correctly display it
Object.defineProperty(this, 'stack', {
value: new Error().stack,
writable: true,
configurable: true
})
// we could also have used
// Error.captureStackTrace(this, this.constructor)
// but it only exists on node and chrome
}
}

Expand Down

0 comments on commit 5ef5d73

Please sign in to comment.