From 5ef5d73fc4118faadbcdaefecbfb50c71ce129a0 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 21 Aug 2019 18:01:01 +0200 Subject: [PATCH] feat(errors): add stack trace to NavigationDuplicated Closes #2881 --- src/history/errors.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/history/errors.js b/src/history/errors.js index 5fd2a626f..1d2118c57 100644 --- a/src/history/errors.js +++ b/src/history/errors.js @@ -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 } }