Provide better diagnostics for exception parse failure
This commit is contained in:
+7
-6
@@ -180,19 +180,20 @@ sqlError err =
|
|||||||
H.UnparsableTemplate t -> t
|
H.UnparsableTemplate t -> t
|
||||||
H.UnparsableRow t -> t
|
H.UnparsableRow t -> t
|
||||||
H.NotInTransaction -> "An operation which requires a"
|
H.NotInTransaction -> "An operation which requires a"
|
||||||
<> "database transaction was executed without one"
|
<> "database transaction was executed without one" in
|
||||||
p = parse message
|
|
||||||
"{\"message\": \"failed to parse exception\" }" inside in
|
|
||||||
either
|
either
|
||||||
(\nope ->
|
(\hint ->
|
||||||
responseLBS status500
|
responseLBS status500
|
||||||
[(hContentType, "application/json")]
|
[(hContentType, "application/json")]
|
||||||
(cs . show $ nope))
|
(cs . encode . object $ [
|
||||||
|
("message", String $
|
||||||
|
"Failed to parse exception:" <> inside)
|
||||||
|
, ("hint", String . cs . show $ hint)]))
|
||||||
(\msg ->
|
(\msg ->
|
||||||
responseLBS (httpStatus msg)
|
responseLBS (httpStatus msg)
|
||||||
[(hContentType, "application/json")]
|
[(hContentType, "application/json")]
|
||||||
(encode msg))
|
(encode msg))
|
||||||
p
|
(parse message "" inside)
|
||||||
|
|
||||||
|
|
||||||
rangeStatus :: Int -> Int -> Int -> Status
|
rangeStatus :: Int -> Int -> Int -> Status
|
||||||
|
|||||||
Reference in New Issue
Block a user