Skip to content

Commit

Permalink
optionalQueryParameter 400 error message
Browse files Browse the repository at this point in the history
- return error message for 400 response error
  • Loading branch information
piq9117 authored and alexbiehl committed Mar 1, 2024
1 parent 1497291 commit 5e1e3ab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Request.template.hs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ optionalQueryParameter name allowEmpty withParam = \request respond ->
| allowEmpty ->
withParam Nothing request respond
| otherwise ->
respond (Wai.responseBuilder (toEnum 400) [] mempty)
respond (Wai.responseBuilder (toEnum 400) [] ("Missing query parameter: " <> name))
Just (Just value) ->
case parseQueryParam (Text.decodeUtf8 value) of
Left _err ->
respond (Wai.responseBuilder (toEnum 400) [] mempty)
respond (Wai.responseBuilder (toEnum 400) [] ("Unable to recognize query parameter: " <> name))
Right x ->
withParam (Just x) request respond
{-# INLINEABLE optionalQueryParameter #-}
Expand Down

0 comments on commit 5e1e3ab

Please sign in to comment.