linter
linter copied to clipboard
Make `avoid_catching_errors` more linient
Issue https://github.com/dart-lang/linter/issues/3023 (dealing with avoid_catches_without_on_clauses
) was also linked as a blocker for enabling the avoid_catching_errors
lint in Flutter and when enabling it I am essentially running into the same classes of problems:
- It flags when
Error
s are caught that are laterrethrow
n after resetting some state. - It flags when
Error
s are caught to then throw a newError
with a more specific error message. - It flags when
Error
s are caught and directly passed to an error processing function (e.g.FlutterError.reportError
)
I am wondering if the same lenience that was extended to avoid_catches_without_on_clauses
in https://github.com/dart-lang/sdk/commit/500a8c0a72851ac95f60685e66df035246ca97c6 in response to https://github.com/dart-lang/linter/issues/3023 should also be applied to avoid_catching_errors
?
FWIW, most of the uncovered reports of avoid_catching_errors
are inside asserts to improve the debugging experience when those Errors happen during development. I wonder if catches in asserts should generally be exempt from the avoid_catching_errors
lint or whether just those specific categories mentioned above should be exempt from the lint.