Preserve URI parse error info in error source chain by veeceey · Pull Request #4025 · hyperium/hyper

Fixes #3043

When hyper parsed an HTTP request with an invalid URI, it would create a Parse(Uri) error but discard the original http::uri::InvalidUri error. This meant error.source() returned None, making it impossible to get the actual reason the URI was invalid.

Changed Parse::Uri to carry an Option<Cause> so the original InvalidUri or InvalidUriParts error flows through to Error::source(). The error message and Display output are unchanged - the improvement is only visible through the Error::source() chain.

Added a test that verifies error.source() returns the original http::uri::InvalidUri:

running 86 tests
...
test error::tests::uri_error_preserves_source ... ok
...
test result: ok. 86 passed; 0 failed; 0 ignored