only_throw_errors

Group: style

Maturity: stable

Linter v0.1.21

Since info is static, may be stale

View all Lint Rules

Using the Linter

DO throw only instances of classes that extend dart.core.Error or dart.core.Exception.

Throwing instances that do not extend Error or Exception is a bad practice; doing this is usually a hack for something that should be implemented more thoroughly.

BAD:

void throwString() {
  throw 'hello world!'; // LINT
}

GOOD:

void throwArgumentError() {
  Error error = ArgumentError('oh!');
  throw error; // OK
}