== Why is this an issue?

Errors should not be created without being thrown because they can confuse and make it difficult to debug code. When an error is thrown, it means that something unexpected has happened, and the program cannot continue executing as expected. By creating an error without throwing it, it may appear as if everything is working correctly, but in reality, an underlying issue must be addressed.

[source,javascript,diff-id=1,diff-type=noncompliant]
----
if (x < 0) {
  new Error("x must be nonnegative"); // Noncompliant: Creating an error without throwing it
}
----

You should make sure to always throw an error that you create using the `throw` keyword.

[source,javascript,diff-id=1,diff-type=compliant]
----
if (x < 0) {
  throw new Error("x must be nonnegative");
}
----

== Resources
=== Documentation

* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error[Error]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw[throw]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling[Control flow and error handling]

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Throw this error or remove this useless statement


include::../highlighting.adoc[]

endif::env-github,rspecator-view[]
