Better error handling in JavaScript

How and why to use custom error types in JavaScript

Handling errors well can be tricky. How Error() historically worked in JavaScript hasn’t made this easier, but using the Error class introduced in ES6 can be helpful

Throwing errors in JavaScript