-
-
Notifications
You must be signed in to change notification settings - Fork 390
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
Reduce repetitive error handling (take two) #68
Reduce repetitive error handling (take two) #68
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! We're almost there.
e5e2052
to
4bfadd0
Compare
quinn-proto/src/endpoint.rs
Outdated
} else { | ||
State::closed(error_code) | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ralith - Maybe a better way to handle these repetitive if else
s. I tried storing the error_code
/reason
in an Option
and then doing a single if else
below, but that didn't work for me.
If you have a good idea I'd love to hear it - otherwise I think this PR should be good to go.
4bfadd0
to
1f2ff49
Compare
…nside handle_connected_inner, mostly in the way of event recording. This patch simplifies this by instead returning a Result, which allows the caller to handle either case and create events more succinctly than handle_connected_inner could. Also, this changeset moves the app_closed property from connection::State to connection::Connection itself, as it is much simpler to manage that piece of state on the Connection itself. Closes quinn-rs#51.
1f2ff49
to
33cc759
Compare
@Ralith - Enumerated all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
+115/-204, very nice! Thanks for sticking with it! If you want to do more, we have a bunch more issues to chose from. 👍 |
Thank you both once again :). Sorry it was a bit of a slog. Learning more on each one! I have my eyes on #64, but have plans to do some reading up on Tokio first as part of the Tokio docs push. I'll leave a comment on the issue itself. |
@djc @Ralith
I managed to botch the rebase on my previous branch, so starting anew here.
Prior to this patch, we had duplicated lots of error handling logic inside
handle_connected_inner
, mostly in the way of event recording. This patch simplifies this by instead returning aResult<State, ConnectionError>
, which allows the caller to handle either case and create events more succinctly thanhandle_connected_inner
could.Also, this changeset moves the
app_closed
property fromconnection::State
toconnection::Connection
itself, as it is much simpler to manage that piece of state on theConnection
itself.Closes #51.