Indicate input json parse error with better message

Fixes #42
This commit is contained in:
Joe Nelson
2014-10-14 19:23:56 -07:00
parent be2f1f8e9e
commit c163e2156c
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ jsonBodyAction req handler = do
parse <- jsonBody req
case parse of
Left err -> return $ responseLBS status400 [jsonContentType] json
where json = JSON.encode . JSON.object $ [("error", JSON.String $ cs err)]
where json = JSON.encode . JSON.object $ [("error", JSON.String $ "Failed to parse JSON payload. " <> cs err) ]
Right body -> handler body
jsonBody :: Request -> IO (Either String SqlRow)