So, quick poll on #JavaScript throw: should you always throw an instance of
Error(), or is it ok to throw anything?

I'm also happy to hear your reasoning for the choice.

Wed, 10 Jan 2018 14:25:27 UTC1

1 reply

Replying to @coderbyheart

You can throw undefined, btw.

I personally think you should always throw an Error instance. Technically this
is superfluous, since everywhere you catch it, you know you have an error.

But: Errors have attached stack traces. So it's easier to debug.