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

[src/error.rs] pub ErrorKind #409

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

SamuelMarks
Copy link

I'm confused how to percolate errors from http through my library.

I want to percolate up a http::uri::ErrorKind::InvalidFormat if .host() is None.

@dekellum
Copy link
Contributor

dekellum commented Apr 3, 2020

The private http::error::ErrorKind shouldn't be in your way, since http::Error has is and get_ref for read access, and implements From<InvalidUri> (if "percolate" includes creating them). However, I see that http::uri::InvalidUri is itself opaque: not user constructable and only offers a description to read. Is that the real issue?

The prominent style here AFAICT, is to never expose a public enum. This unfortunately tends to leave users with only a description string, but #303 demonstrates willingness to improve usability in other ways. Perhaps kind-specific constructor functions and is_<kind>(&self) -> bool (e.g. is_invalid_format) methods could be added to InvalidUri?

@SamuelMarks
Copy link
Author

@dekellum So how do I create a http::uri::InvalidUri in my codebase?

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.

None yet

2 participants