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

Reduce repetitive error handling (take two) #68

Merged
merged 1 commit into from
Oct 17, 2018

Conversation

twilco
Copy link
Contributor

@twilco twilco commented Oct 16, 2018

@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 a Result<State, ConnectionError>, 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 #51.

Copy link
Collaborator

@Ralith Ralith left a 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.

quinn-proto/src/endpoint.rs Outdated Show resolved Hide resolved
quinn-proto/src/endpoint.rs Outdated Show resolved Hide resolved
@twilco twilco force-pushed the reduce-repetitive-err-handling-take-two branch from e5e2052 to 4bfadd0 Compare October 16, 2018 05:01
} else {
State::closed(error_code)
}
},
Copy link
Contributor Author

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 elses. 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.

@twilco twilco force-pushed the reduce-repetitive-err-handling-take-two branch from 4bfadd0 to 1f2ff49 Compare October 16, 2018 14:50
quinn-proto/src/endpoint.rs Outdated Show resolved Hide resolved
…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.
@twilco twilco force-pushed the reduce-repetitive-err-handling-take-two branch from 1f2ff49 to 33cc759 Compare October 16, 2018 19:01
@twilco
Copy link
Contributor Author

twilco commented Oct 16, 2018

@Ralith - Enumerated all ConnectionError types. Please re-review!

Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@djc djc merged commit dc41b8b into quinn-rs:master Oct 17, 2018
@djc
Copy link
Member

djc commented Oct 17, 2018

+115/-204, very nice! Thanks for sticking with it! If you want to do more, we have a bunch more issues to chose from. 👍

@twilco
Copy link
Contributor Author

twilco commented Oct 17, 2018

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.

@twilco twilco deleted the reduce-repetitive-err-handling-take-two branch October 17, 2018 14:57
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 this pull request may close these issues.

Factor out common error handling code
3 participants