Raise ContentTypeError by json() when headers does not …#2136
Merged
asvetlov merged 5 commits intoaio-libs:masterfrom Jul 27, 2017
Merged
Raise ContentTypeError by json() when headers does not …#2136asvetlov merged 5 commits intoaio-libs:masterfrom
asvetlov merged 5 commits intoaio-libs:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2136 +/- ##
==========================================
+ Coverage 97.07% 97.07% +<.01%
==========================================
Files 38 38
Lines 7723 7728 +5
Branches 1346 1347 +1
==========================================
+ Hits 7497 7502 +5
Misses 102 102
Partials 124 124
Continue to review full report at Codecov.
|
Member
|
The intention is pretty clean but |
Contributor
Author
|
Exception name changed to |
Member
|
Thanks! |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What do these changes do?
Basically, avoid having a nocive fall back as the following one
The
ClieintResponseErrorcan be raised by many reasons, and the case presented the fallback can be misleading having as a result twiceClieintResponseErrorbecause the source of the problem wasn't related to the content type.With an ad-hoc exception, the client can code a more specific fallback case taking into account the differents source of problems with a cleaner interface, for example:
Thanks to the current
json()implementation once we have had aContentTypeErrorexception is not possible to have aClieintResponseError. Therefore, the developer can handle the errors as the previous example.For backward compatibility the
ContentTypeErrorinherits fromClieintResponseError.Are there changes in behavior for the user?
No
Checklist
CONTRIBUTORS.txtchangesfolder<issue_id>.<type>for example (588.bug)issue_idchange it to the pr id after creating the pr.feature: Signifying a new feature..bugfix: Signifying a bug fix..doc: Signifying a documentation improvement..removal: Signifying a deprecation or removal of public API..misc: A ticket has been closed, but it is not of interest to users.