Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 537 Bytes

use_rethrow_when_possible.md

File metadata and controls

31 lines (24 loc) · 537 Bytes

Pattern: Missing use of rethrow

Issue: -

Description

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

Example of incorrect code:

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

Example of correct code:

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

Further Reading