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

Remove exceptions from network code #6602

Closed
glebm opened this issue Sep 15, 2023 · 0 comments · Fixed by #6820
Closed

Remove exceptions from network code #6602

glebm opened this issue Sep 15, 2023 · 0 comments · Fixed by #6820

Comments

@glebm
Copy link
Collaborator

glebm commented Sep 15, 2023

Network code is the only place in the codebase where we use exceptions.

Removing exceptions from network code will pave a path for network support on platforms that do not support exceptions (e.g. nxdk). I also think it will make the code easier to follow.

Exceptions can be replaced with tl::expected.

ASIO can be configured to avoid exceptions, we just need to provide a custom "throw" implementation. More information from @StephenCWills:

Found some info for building ASIO without exceptions.
chriskohlhoff/asio#302 (comment)

Here's an option I thought of based on your work in this PR. Something like...

tl::expected<void, PacketError> tcp_client::poll()
{
	while (ioc.poll_one() > 0) {
		if (ioHandlerError != nullptr)
			return t1::make_unexpected(*ioHandlerError);
	}
}
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

Successfully merging a pull request may close this issue.

1 participant