Skip to content

Exceptions in coroutines? #22

@niansa

Description

@niansa

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions