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

Exceptions in coroutines? #22

Open
niansa opened this issue Jan 26, 2023 · 2 comments
Open

Exceptions in coroutines? #22

niansa opened this issue Jan 26, 2023 · 2 comments

Comments

@niansa
Copy link

niansa commented Jan 26, 2023

Hey!

Boost allows you to catch exceptions from the coroutine caller, so this totally works there:

try {
    co_await connect_to_server();
} catch (const connection_refused&) {
    std::cerr << "Connection refused\n";
}

libasync however, doesn't seem to allow that, it just executes std::terminate. Imo this is quite bad, since one of the reasons for why I wanted coroutines is so that I can use exceptions instead of error codes... and here I am again, using error codes :-/

There should at least be an optional feature to allow this!

Thanks
niansa

@avdgrinten
Copy link
Member

There's no technical reason why this cannot work, we just didn't implement it. If you have a (partial) implementation, we'd gladly merge it.

Adding support to the basic coroutine types (like async::result) would probably be easy, propagating it through all algorithms might be a bit more work.

@niansa
Copy link
Author

niansa commented Jan 27, 2023

That'd be absolutely amazing! Thanks a lot for the hard work put into this :-)

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

No branches or pull requests

2 participants