Skip to content

Commit 5ef5d73

Browse files
committed
feat(errors): add stack trace to NavigationDuplicated
Closes #2881
1 parent 5141def commit 5ef5d73

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/history/errors.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
export class NavigationDuplicated extends Error {
2-
constructor () {
3-
super('Navigating to current location is not allowed')
2+
constructor (normalizedLocation) {
3+
super()
44
this.name = this._name = 'NavigationDuplicated'
5+
// passing the message to super() doesn't seem to work in the transpiled version
6+
this.message = `Navigating to current location ("${
7+
normalizedLocation.fullPath
8+
}") is not allowed`
9+
// add a stack property so services like Sentry can correctly display it
10+
Object.defineProperty(this, 'stack', {
11+
value: new Error().stack,
12+
writable: true,
13+
configurable: true
14+
})
15+
// we could also have used
16+
// Error.captureStackTrace(this, this.constructor)
17+
// but it only exists on node and chrome
518
}
619
}
720

0 commit comments

Comments
 (0)