Should I use console.error() or throw new Error()

milena_komnenic_395b0feeb

Milena Komnenic

Posted on August 20, 2024

Should I use console.error() or throw new Error()

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_395b0feeb
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.

Related

ยฉ TheLazy.dev

About