You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm expecting to get Test in constructor and full stacktrace in e.stack, and everything works as I expect:
Constructor: class Test extends Error {
constructor() {
super();
Error.captureStackTrace(this, this.constructor)
console.log('Constructor: ', this.constructor);
}
}
Stack: Error
at Object.<anonymous> (/Users/rostik404/projects/test-project/test-error.js:42:11)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:974:3
After babel transformation, I'm getting this code:
Hey @rostik404! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.
That said, even using that builtin-extend plugin, which makes .nameTest, the stack trace itself does seem to still contain Error. I'm not sure there's anything we can do there, I have no idea how Chrome decides what to use when building traces.
After babel transformation, custom error loses its stacktrace because of incorrect value in
_this.constructor
.Input Code
Here is a simple example of custom js Error:
I'm expecting to get
Test
in constructor and full stacktrace ine.stack
, and everything works as I expect:After babel transformation, I'm getting this code:
And in this code, I'm getting
Error
in_this.constructor
instead ofTest
and because of thisError.capturestacktrace
cuts the whole stacktrace:Babel Configuration (.babelrc, package.json, cli command)
Using babel online
Expected Behavior
Full stacktrace in custom Error
Current Behavior
Cut stacktrace and incorrect value in
_this.constructor
Your Environment
The text was updated successfully, but these errors were encountered: