throw statement 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

View with compliant examples side by side
if (x === null) {
    new Error("x should not be null"); // MISSING_THROW alarm
}

Compliant Code Example

View with noncompliant examples side by side
if (x === null) {
    throw new Error("x should not be null");
}

Version

This rule was introduced in DeepScan 1.0.0-alpha.

Was this documentation helpful?