refactor make_response to be easier to follow#2256
Merged
davidism merged 1 commit intopallets:masterfrom Apr 25, 2017
davidism:refactor-make_response
Merged
refactor make_response to be easier to follow#2256davidism merged 1 commit intopallets:masterfrom davidism:refactor-make_response
davidism merged 1 commit intopallets:masterfrom
davidism:refactor-make_response
Conversation
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.
bytesfor status valueHeadersfor headers valueTypeErrorinstead ofValueErrorNonecloses #1676
TypeErroris more correct by definition (wrong type to function), and I don't think anyone should be catching that error anyway (what would it mean to do that?), so I'm ok if this somehow breaks some code. This is also consistent with whatforce_typereturns for bad input.I had to get a bit creative with displaying the error from
force_typewhile injecting a new descriptive message. It would be nice if we could just useraise new_error from original_error, but that's Python 3 only.These error messages will hopefully help avoid a class of questions that are frequently asked on Stack Overflow. In particular, there was no error about incorrect types that made it to
force_type, so users trying to return JSON with something likereturn Truewould get a mysterious "bool object is not callable" error.