All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.javascript.rules.javascript.S3984.html Maven / Gradle / Ivy

There is a newer version: 5.0.0.6962
Show newest version

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.

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.

if (x < 0) {
  throw new Error("x must be nonnegative");
}

Resources

Documentation





© 2015 - 2025 Weber Informatics LLC | Privacy Policy