3 ms·
As a rule of thumb: never throw something that isn't an Error. Please, let's keep our code a little bit more sane. If you want to define your own errors classe
by TheAceOfHearts 10y ago
As a rule of thumb: never throw something that isn't an Error. Please, let's keep our code a little bit more sane.
If you want to define your own errors classes, I've had no complaints when using the following module: es6-error [0]. It lets you define new error classes which extend Error without any problems.
If you don't wanna pull in a module, the following StarOverflow answer [1] shows how to define a custom error that works everywhere.
[0] https://www.npmjs.com/package/es6-error https://www.npmjs.com/package/es6-error
[1] http://stackoverflow.com/a/35881508/1505117 http://stackoverflow.com/a/35881508/1505117