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

Confusing code example in futures-error-handling guide #373

Closed
BorisNaguet opened this issue Sep 6, 2017 · 4 comments
Closed

Confusing code example in futures-error-handling guide #373

BorisNaguet opened this issue Sep 6, 2017 · 4 comments
Assignees
Labels
fix.bug Needs fix of incorrect copy, code, or visual

Comments

@BorisNaguet
Copy link

Hello,

on this page:
https://www.dartlang.org/guides/libraries/futures-error-handling#completing-the-future-returned-by-whencomplete

this example:

void main() {
  funcThatThrows()
    .then((_) => print("Won't reach here..."))   // Future completes with an error.
    .whenComplete(() => print("... or here...")) // Future completes with the same error.
    .then((_) => print("... nor here."))         // Future completes with the same error.
    .catchError(handleError)                     // Error is handled here.
}

It's confusing, because "Won't reach here, or here, nor here" seems to mean that it won't be printed.
But "... or here..." is actually printed (but the error is transmitted on the next Future as the comments explain correctly).

I think it would be clearer with an executable code in dartpad like on other parts of the site.

@lrhn
Copy link
Member

lrhn commented Sep 6, 2017

I agree that it is so misleading that it's probably just wrong. The whenComplete part should, and will, be printed.

@kwalrath kwalrath added the fix.bug Needs fix of incorrect copy, code, or visual label Sep 6, 2017
@kwalrath
Copy link
Contributor

kwalrath commented Sep 6, 2017

@BorisNaguet you've convinced me that the page should feature DartPad. (I think its original version was from before DartPad's existence.)

@kwalrath kwalrath self-assigned this Sep 6, 2017
@Sfshaza
Copy link

Sfshaza commented Sep 6, 2017

Yes, this piece was written years ago by our DPE, and long before DartPad existed. I think it's a great idea!

@kwalrath
Copy link
Contributor

Related to #407.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix.bug Needs fix of incorrect copy, code, or visual
Projects
None yet
Development

No branches or pull requests

4 participants