Timeline for What's a good way to extend Error in JavaScript?
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 2, 2019 at 10:54 | comment | added | Aurelio |
Worth noting that the issue with console.log(new CustomError('test') instanceof CustomError);// false was true at the time of writing but has now been resolved. In fact the issue linked in the answer has been resolved and we can test the correct behaviour here and by pasting the code in the REPL and seeing how it gets correctly transpiled to instantiate with the correct prototype chain.
|
|
Feb 21, 2019 at 19:54 | comment | added | Iulian Pinzaru | This helped me in solving the problem with inheriting from "Error". It was a two hours nightmare! | |
Jul 15, 2018 at 17:53 | comment | added | Andrew Smith | This actually provides the most comprehensive solution and explains why the various pieces are necessary. Thanks so much JBE! | |
Mar 15, 2018 at 17:16 | comment | added | Daniele Orlando | Very complete answer. | |
S Sep 21, 2017 at 8:14 | history | suggested | Indolering | CC BY-SA 3.0 |
Removed reference to Babel-specific QA post in section that excluded transpilers.
|
Sep 21, 2017 at 3:30 | review | Suggested edits | |||
S Sep 21, 2017 at 8:14 | |||||
Sep 19, 2017 at 13:53 | history | edited | JBE | CC BY-SA 3.0 |
deleted 2 characters in body
|
Sep 19, 2017 at 13:46 | comment | added | Indolering |
class CustomError extends Error { /* ... */} doesn't correctly handle vendor-specific arguments (lineNumber , etc), 'Extending Error in Javascript with ES6 syntax' is Babel specific, your ES5 solution uses const and it doesn't handle custom arguments.
|
|
May 23, 2017 at 11:47 | history | edited | URL Rewriter Bot |
replaced http://stackoverflow.com/ with https://stackoverflow.com/
|
|
Apr 24, 2017 at 18:17 | history | edited | JBE | CC BY-SA 3.0 |
added 146 characters in body
|
Apr 24, 2017 at 18:11 | history | answered | JBE | CC BY-SA 3.0 |