Preserve URI parse error info in error source chain#4025
Open
veeceey wants to merge 1 commit intohyperium:masterfrom
Open
Preserve URI parse error info in error source chain#4025veeceey wants to merge 1 commit intohyperium:masterfrom
veeceey wants to merge 1 commit intohyperium:masterfrom
Conversation
When an invalid URI is parsed by the http crate, the InvalidUri error contains useful details about what part of the URI was invalid. Previously this information was discarded when converting to hyper::Error. Now the original InvalidUri/InvalidUriParts error is stored as the source of the hyper::Error, making it available through the standard Error::source() chain and downcastable to the concrete type. Closes hyperium#3043
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3043
When hyper parsed an HTTP request with an invalid URI, it would create a
Parse(Uri)error but discard the originalhttp::uri::InvalidUrierror. This meanterror.source()returnedNone, making it impossible to get the actual reason the URI was invalid.Changed
Parse::Urito carry anOption<Cause>so the originalInvalidUriorInvalidUriPartserror flows through toError::source(). The error message andDisplayoutput are unchanged - the improvement is only visible through theError::source()chain.Added a test that verifies
error.source()returns the originalhttp::uri::InvalidUri: