throw should be used to actually throw an exception

  • MISSING_THROW
  • Error
  • Medium
  • No tags

This rule applies when an exception instance is created but is not either referenced or thrown at all.

In such a case, it is highly probable that throw is unintentionally missing.

Noncompliant Code Example

if (x === null) {
    new Error("x should not be null"); // MISSING_THROW alarm
}

Compliant Code Example

if (x === null) {
    throw new Error("x should not be null");
}

Version

This rule was introduced in DeepScan 1.0.0-alpha.