Throw error on query parameter parse failure #649
Closed
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.
QueryParam
andQueryParams
passNothing
to the handler when parsing the parameters fails. This is counter-intuitive and IMO makes the parsing functionality almost useless.This pull-request changes the HasServer instance to throw error400 when parsing fails. In case where parse failures are to be dealt with gracefully the user can define a new type:
or similar or just take
Text
parameters directly.(Maybe servant should provide this for convenience?)
Related to #256
Technical Details:
serverD
block to theDelayed
type because none of the existing blocks seemed to be appropriate. The block is executed last, even after bodyD because this is the only way to guarantee that 400 has the least priority (bodyD can also return 406 and 415)RFCs:
And of course this would greatly aid debugging of requests, but I left this as a TODO because I wasn't sure what format to put the error messages in and whether to include the parse errors.
Header
s could use the sameDelayed
block, but this isn't implemented in this PR (yet?). In this case it might be better to rename it to something different thanparamD
. Suggestions?