Should I use console.error() or throw new Error()
Milena Komnenic
Posted on August 20, 2024
Both error handling ways seem reliable and used. But my question is:
Is there a difference between them? And if there is, when should I use which?
The key difference is: throwing halts the execution, while console.error does not.
Most of the time, it's better to throw an error.
The problem with console.error is that it does not really throw an error that stops the execution of the program , something that throw Error does .
๐ ๐ช ๐
๐ฉ
Milena Komnenic
Posted on August 20, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.