-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Escape from uncaught exceptions for IDEs #2104
Conversation
Signed-off-by: Ericsson <[email protected]>
@EricssonXD Hi, thanks for taking the time to investigate the cause. Very much appreciated! I was wonder if adding the paired |
Could also help to identify if this is relevant fix for #1869? |
As the function is a parameter that gets passed to the interceptor, which expects a |
Is there any reasons why you would like to avoid |
Signed-off-by: Ericsson <[email protected]>
You may spot that we've already implemented |
That's actually what I wrote initially during debugging but I found out adding only the await keyword somehow made it work which lead to my proposed code. I have updated my code now, but I don't quite understand what do you mean by
Isn't this new code also awaiting a future that is not void? Or do you mean like we shouldn't await a value that is not void if we are not using it? |
What I mean is we shouldn't wait for a future that returns value but not use it eventually. In general: Future<String> foo() async {
await Future(() {});
return 'bar';
}
void main() async {
// Good.
final result = await foo();
print(result);
// Bad.
await foo();
} |
Ahhh I see, are there any more problems that I should address in my pull request? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit:
I'd consider the request as test exempt, as it doesn't affect any actual behavior. Waiting for other inputs. |
@kuhnroyal @ueman Any inputs? |
Going to merge this and apply inputs if any in the future. |
Signed-off-by: Alex Li <[email protected]>
I think the fix for the root cause is out in Dart:master now. But this looks cleaner in any case. |
I faced the same issue as #314 and #1869, and I also understand that it is not an error with the dio package but an error with the Flutter SDK / VScode, where VScode does not recognise the exceptions as handled when using Future.catchError().
Despite it not being a problem of this package, I believe "fixing" it such that it avoids the above mentioned problem is still the correct approach, the following modification avoids this problem, and allows the example Error Handling code on pub.dev works with VScode.
New Pull Request Checklist
main
branch to avoid conflicts (via merge from master or rebase)CHANGELOG.md
in the corresponding packageAdditional context and info (if any)