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

http::Error is completely opaque #302

Closed
dekellum opened this issue Mar 12, 2019 · 2 comments
Closed

http::Error is completely opaque #302

dekellum opened this issue Mar 12, 2019 · 2 comments

Comments

@dekellum
Copy link
Contributor

The http::Error type, the higher level error returned from various http builders, is missing a commonly advocated/desired facility for programmatic access. I suspect this was just an oversight of its late addition, not the intent. Currently http::Error is as opaque as any StringError, so for example when building a response via response::Builder, the only way to distinguish between InvalidHeaderName and InvalidStatusCode is by testing Error::to_string, Display or Debug format string.

The only other workaround is to not use the builder types, where that is possible, as for this example using Response::from_parts, etc., but we prefer using the builders for ergonomics.

@carllerche
Copy link
Collaborator

Hmm... the goal is to avoid tight coupling between error types.

It could be exposed via a http::Error::downcast_ref::<T>() -> Option<&T> type of fn. Thoughts @seanmonstar?

@dekellum
Copy link
Contributor Author

Yep, I understand that something like this was necessary for the builders, to return a single error type on the final "building" call. Its just missing some way to test for certain causes, which are already exported, lower level error types, e.g. InvalidHeaderName.

For implementation I think #303 has some advantage, but I'll comment on that there.

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

No branches or pull requests

2 participants