use_rethrow_when_possible

Group: style

Maturity: stable

Linter v0.1.31

Since info is static, may be stale
recommendedflutterpedantic

View all Lint Rules

Using the Linter

DO use rethrow to rethrow a caught exception.

As Dart provides rethrow as a feature, it should be used to improve terseness and readability.

BAD:

try {
  somethingRisky();
} catch(e) {
  if (!canHandle(e)) throw e;
  handle(e);
}

GOOD:

try {
  somethingRisky();
} catch(e) {
  if (!canHandle(e)) rethrow;
  handle(e);
}