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

future::error() interface is odd #264

Closed
sean-parent opened this issue May 30, 2019 · 2 comments
Closed

future::error() interface is odd #264

sean-parent opened this issue May 30, 2019 · 2 comments

Comments

@sean-parent
Copy link
Member

The error() function returns an optional<exception_ptr>. Wouldn't just a, possibly null, exception_ptr be sufficient? (I know we perhaps have two states here, ready, and an exception occurred, perhaps we can collapse that and add a ready() or status() member. The name is also a bit unexpected, I would expect it to be called exception() to match set_exception(). We could add exception() as a non-breaking change and deprecate error(). The current form makes writing recover() extra painful (see issue #263):

f.recover([](auto f) {
    auto e = f.error();
    if (e && *e) //...
}

compared to:

f.recover([](auto f) {
    if (auto e = f.exception()) //...
}
@FelixPetriconi
Copy link
Member

What would be the purpose of ready()? We already have an is_ready() function?

@FelixPetriconi
Copy link
Member

Fixed in 1.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants