Skip to main content
18 events
when toggle format what by license comment
Jun 1, 2023 at 21:24 review Suggested edits
Jun 2, 2023 at 9:02
Apr 23, 2023 at 20:26 review Suggested edits
Apr 24, 2023 at 3:04
Dec 23, 2020 at 14:11 comment added bFunc Correct me if I am wrong please. As far as I can see simple direct extending of Error class works fine in Chrome console, in Webpack with default settings and in ReactCreateApp without side effects. Reference here: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
Feb 12, 2020 at 14:34 comment added John Weisz @КонстантинВан That's unfortunately only an option without class-name minification.
May 16, 2019 at 19:10 comment added Nicolas NZ This already works in the latest babel preset, they fixed the instanceof issue, also minified bugs are probably wrong minifier configs
Dec 22, 2018 at 18:33 review Suggested edits
Dec 23, 2018 at 10:18
Dec 22, 2018 at 18:30 comment added Aalex Gabi @ChristianIvicevic You need to configure classes that you want to be excluded from mangling: github.com/mishoo/UglifyJS2/issues/1429#issuecomment-346401764
Dec 19, 2018 at 22:39 comment added Christian Ivicevic @AalexGabi In minified code you will get a nonsensical name instead of a human readable class name as intended. So basically it works, but semantically yields an undesirable result.
Dec 19, 2018 at 15:12 comment added Aalex Gabi @ChristianIvicevic This should work. If it doesn't you should check the minifier settings or the minifier has a bug.
Dec 19, 2018 at 15:02 review Suggested edits
Dec 19, 2018 at 16:03
Feb 2, 2018 at 10:09 comment added Константин Ван For ease of maintaining, use this.name = this.constructor.name; instead.
Apr 4, 2017 at 18:26 comment added Martin Ždila To assign name use rather MyError.prototype.name = 'MyError'.
Dec 22, 2016 at 23:34 comment added Matt Browne For browsers, note that you can detect support for classes at runtime and fall back to a non-class version accordingly. Detection code: var supportsClasses = false; try {eval('class X{}'); supportsClasses = true;} catch (e) {}
Dec 22, 2016 at 23:33 comment added Matt Browne This is the best way to do it when possible. Custom errors behave more like regular errors in both Chrome and Firefox (and probably other browsers too).
Dec 11, 2016 at 20:02 history edited Kostanos CC BY-SA 3.0
having this.message = message is redundant, parent class does it
Jun 16, 2016 at 7:09 comment added Ace If you are using babel and are on node > 5.x you shouldn't be using the es2015 preset but npmjs.com/package/babel-preset-node5 would allow you to use native es6 extends plus more
Jan 6, 2016 at 1:01 comment added aaaidan Worth mentioning that this doesn't work if you are using ES6 features via a transpiler, such as Babel, since subclasses must extend a class.
Sep 23, 2015 at 22:51 history answered Mohsen CC BY-SA 3.0