avoid_catches_without_on_clauses

Group: style

Maturity: stable

Dart SDK: >= 2.0.0 • (Linter v0.1.31)

View the Project on GitHub dart-lang/linter

AVOID catches without on clauses.

Using catch clauses without on clauses make your code prone to encountering unexpected errors that won't be thrown (and thus will go unnoticed).

BAD:

try {
 somethingRisky()
}
catch(e) {
  doSomething(e);
}

GOOD:

try {
 somethingRisky()
}
on Exception catch(e) {
  doSomething(e);
}