-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
P4area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-lint-proposaltype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
I suggest the lint uncaught_async_error_in_try_catch (or a better name), for the example bellow:
/// Here the call to [_computeImpl] should trigger a warning,
/// since the `try` block won't catch any error from `_computeImpl`:
Future<int?> compute1(String value) async {
try {
return _computeImpl(value) ;
} catch(_) {
return null ;
}
}
/// This is the fixed version, where the `await` ensures
/// that the `try` block will catch errors.
Future<int?> compute2(String value) async {
try {
return await _computeImpl(value) ;
} catch(_) {
return null ;
}
}
/// A simple computation that can trigger an [ArgumentError].
Future<int?> _computeImpl(String value) async {
if (value.isEmpty) {
throw ArgumentError("Empty `value`");
}
return value.length ;
}
Without a lint the issue above is not simple to detect and debug and can generate many bugs.
Metadata
Metadata
Assignees
Labels
P4area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-lint-proposaltype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug