Hard to subclass with ES6 `class` syntax
mathew-kurian opened this issue · 4 comments
I not 100% sure I don't think this class meets the class
es6 specifications because you are overriding the stack
attribute which makes it hard to extend and modify the stack
property via class inheritance offered in ES6. I had recently made a library https://github.com/bluejamesbond/TraceError.js. If you think, this offers a potential benefits, I would happy to provide a pull request into your library.
I can see the advantages of the approach you took. If you want to submit a PR I'd be happy to merge it. If not, I might look at making that change myself. Thanks for the idea.
I feel that we are both trying to solve the same problem here. Would you like to merge the two libraries together to simplify maintainability? At the moment, I have support for node >= 0.11. It is not tested for browsers; however, from the logic it can support those that have setPrototypeOf
, getPrototTypeOf
, defineProperty
, and getOwnPropertyDescriptors
(or at least polly-filled).
I'm always up for improvements. It looks like https://github.com/bluejamesbond/TraceError.js is just starting out, if you put the time into improving this project it will have a wide impact right away with the existing dependent projects.
You point out good improvement for ES6 support and subclassing, but people are already using this project with a range of node versions 0.10 through 4 at least. I know my projects use node 4.4 and I know of at least a couple of others who are too. Perhaps most people don't want to subclass and also extend the stack property?
I understand. The stack extension generally allows multiple layers of transpilers which allows different forms of stacktraces to be mapped to the source especially with the advent of ES6 and Babel/TypeScript/JSX. That being said, this library is not yet being supported in 0.10 which is definitely an incompatibility. Additionally, if you see any issues with the library atm let me know; I would be happy to address it.