From 08307723840ac5b2ba50fe916659aeb93840eb66 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Mon, 22 Dec 2014 15:40:20 -0800 Subject: [PATCH] Provide better diagnostics for exception parse failure --- src/App.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/App.hs b/src/App.hs index 06f4b0586..fa0a71700 100644 --- a/src/App.hs +++ b/src/App.hs @@ -180,19 +180,20 @@ sqlError err = H.UnparsableTemplate t -> t H.UnparsableRow t -> t H.NotInTransaction -> "An operation which requires a" - <> "database transaction was executed without one" - p = parse message - "{\"message\": \"failed to parse exception\" }" inside in + <> "database transaction was executed without one" in either - (\nope -> + (\hint -> responseLBS status500 [(hContentType, "application/json")] - (cs . show $ nope)) + (cs . encode . object $ [ + ("message", String $ + "Failed to parse exception:" <> inside) + , ("hint", String . cs . show $ hint)])) (\msg -> responseLBS (httpStatus msg) [(hContentType, "application/json")] (encode msg)) - p + (parse message "" inside) rangeStatus :: Int -> Int -> Int -> Status