avoid-identical-exception-handling-blocks
Warns when a try / catch has multiple catch blocks with the same body.
Consider adding additional information for each caught exception.
Example
❌ Bad:
void main() {
try {
print('hello');
} on StateError catch (error) {
print(error);
} on Exception catch (error) {
print(error); // LINT: Avoid identical exception handling blocks. Try adding additional information for each caught exception.
}
}
✅ Good:
void main() {
try {
print('hello');
} on StateError catch (error) {
print('Got StateError $error');
} on Exception catch (error) {
print('Got Exception $error'); // Correct, different error handler
}
}