Skip to content
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

Implement DON’T discard errors from catches without on clauses. #57494

Closed
JPaulsen opened this issue Mar 23, 2017 · 4 comments
Closed

Implement DON’T discard errors from catches without on clauses. #57494

JPaulsen opened this issue Mar 23, 2017 · 4 comments
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.

Comments

@JPaulsen
Copy link
Contributor

JPaulsen commented Mar 23, 2017

From Effective Dart

@JPaulsen
Copy link
Contributor Author

JPaulsen commented Mar 23, 2017

@bwilkerson @pq is this necessary to implement? Because if you have something like this.

try {
}
catch(e) {
  // ignore
}

The analyzer will say: "The exception variable 'e' is not used, so the 'catch' clause can be removed."

@zoechi
Copy link
Contributor

zoechi commented Mar 23, 2017

I don't get a hint for the unused variable 'e' with above code.

I also don't get any hint for

try {
}
catch(_) {}

@bwilkerson
Copy link
Member

There is no hint when the exception parameter is not used and there is no on clause because at that point the exception parameter is required and there isn't any reasonable way the user could get rid of the hint.

is this necessary to implement?

How would you catch this case? Any exception parameter that is not referenced within the catch clause? It will be marked as dead code if there is an on clause, and I don't think it's useful to create a lint that cannot be removed. I don't think we need a lint for this.

@JPaulsen
Copy link
Contributor Author

You were right, without on clauses it does not hint that.

And yes, if it has the on clause it will be mark as dead code, and without the on will be linted as avoid lints without on, so I will close this issue.

@devoncarew devoncarew added analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 18, 2024
@devoncarew devoncarew transferred this issue from dart-lang/linter Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Projects
None yet
Development

No branches or pull requests

4 participants