hyper icon indicating copy to clipboard operation
hyper copied to clipboard

feat(error): preserve `InvalidUri` details

Open hawkw opened this issue 2 years ago • 2 comments

This branch changes the representation of the Parse::Uri error kind to preserve information provided by the http crate's uri::InvalidUri and uri::InvalidUriParts errors. A new InvalidUri enum is added that holds one of those two error types, or a custom message (since hyper currently returns Parse::Uri errors that didn't come from an inner http error in some cases). The new enum has a custom Display and Debug implementation to reduce repetition of the string "invalid URI" in its formatted output.

This is not stored as the error's cause currently in order to avoid exposing the http crate's error types in the public API. However, when http 1.0 is released, we can simplify this code significantly by storing the error as a cause and exposing it in the source chain.

Closes #3043

hawkw avatar Nov 04 '22 17:11 hawkw

This is not stored as the error's cause currently in order to avoid exposing the http crate's error types in the public API.

hyper already exposes http publicly, and http will need to be marked 1.0 before hyper. If it does make things easier, than we can just do that.

seanmonstar avatar Nov 07 '22 14:11 seanmonstar

@seanmonstar In that case, it might be nicer to expose http's errors as a source and downcast_ref target!

hawkw avatar Nov 07 '22 19:11 hawkw