feat(error): revamp hyper::Error
type
#1480
Merged
+514
−402
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.
The
Error
is now an opaque struct, which allows for more variants tobe added freely, and the internal representation to change without being
breaking changes.
For inspecting an
Error
, there are severalis_*
methods to check forcertain classes of errors, such as
Error::is_parse()
. Thecause
canalso be inspected, like before. This likely seems like a downgrade, but
more inspection can be added as needed!
The
Error
now knows about more states, which gives much more contextaround when a certain error occurs. This is also expressed in the
description and
fmt
messages.Most places where a user would provide an error to hyper can now pass
any error type (
E: Into<Box<std::error::Error>>
). This error is passedback in relevant places, and can be useful for logging. This should make
it much clearer about what error a user should provide to hyper: any it
feels is relevant!
Closes #1128
Closes #1130
Closes #1431
Closes #1338
BREAKING CHANGE:
Error
is no longer an enum to pattern match over, orto construct. Code will need to be updated accordingly.
For body streams or
Service
s, inference might be unable to determinewhat error type you mean to return. Starting in Rust 1.26, you could
just label that as
!
if you never return an error.