-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Wildcard Variables] empty_catches
support
#57132
Comments
According to the details section, that already is good enough? |
The goal of the lint is to avoid accidentally not handling an error, forgetting to put something in the catch clause. } catch (e) {
// Remember to handle the error!
} is also a false negative. A catch-all is always a code smell. There are places where it's needed, around untrusted self-contained code being run by a framework, but generally one shouldn't ignore errors. This lint is not enforcing that, it's just making sure you intended it, and |
Thanks, @lrhn.
EDIT: I should have looked closer. This is ALREADY how it's implemented. (Nothing more non-breaking than a non-change!) As for whether we should start reporting on /fyi @goderbauer @mit-mit @dart-lang/language-team @dart-lang/analyzer-team (Comments and up/down votes welcome.) |
Proposal: do lint This would be breaking and would introduce new diagnostics. The rationale would be to further nudge people towards using wildcards. |
Alternatively, we could nudge users to wildcards by flagging the try {
} catch(e) {
// Unused.
} as unused by producing an EDIT: as @bwilkerson points out, |
The try {
// ...
} on Object catch (_) {
} the catch clause would still be unnecessary and should still be reported by |
Oh, right! I got the diagnostics confused and was thinking about the idea of beginning to report an That is: try {
} catch(e) { // UNUSED_LOCAL_VARIABLE
} but not: try {
} catch(_) {
} See: #55719. |
Yes, if there's no |
Closing in favor of conversation in #56595 |
Summary: User suggests that |
Today if you want to catch and ignore an exception you can silence
empty_catches
by adding a comment to the catch clause,With wildcards, I wonder if this shouldn't be sufficient to silence the lint?
EDIT: this is already how it's implemented but there's an open question about whether we want to start reporting on the non-wildcard (
catch(e)
) case.The text was updated successfully, but these errors were encountered: