Add a new lint to catch dead code in try catch around syncronous code working with futures #59111
Labels
area-devexp
For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
devexp-linter
Issues with the analyzer's support for the linter package
linter-lint-request
P3
A lower priority bug or feature request
type-enhancement
A request for a change that isn't a bug
Describe the rule you'd like to see added and to what rule set
I have a function like this in a library wrapper class:
This does not work as intended, because the function is not marked
async
. Instead of catching the error from the implementation, it returns theFuture.error
value containing anImplementationException
.The correct implementation would look like this:
Additional context
I would like some sort of lint message for the function, as it contains dead code in the try catch.
I'm not sure if this can be generalised for all functions. Dart can't really know if I wanted to catch a synchronous or async error with the try catch. Maybe having a lint that forces all functions returning Futures to be
async
would help? I would prefer if there were no syncronous functions operating on futures at all in the project to avoid issues like this.The text was updated successfully, but these errors were encountered: