Read settings from config file (#714)

This commit is contained in:
Joe Nelson
2016-10-20 08:34:57 -07:00
committed by GitHub
parent 74e68408e6
commit 9233d90075
6 changed files with 121 additions and 46 deletions
+6 -1
View File
@@ -2,7 +2,7 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}
module PostgREST.Error (pgErrResponse, errResponse) where
module PostgREST.Error (pgErrResponse, errResponse, prettyUsageError) where
import Protolude
import Data.Aeson ((.=))
@@ -29,6 +29,11 @@ pgErrResponse authed e =
else [jsonType] in
responseLBS status hdrs (JSON.encode e)
prettyUsageError :: P.UsageError -> Text
prettyUsageError (P.ConnectionError e) =
"Database connection error:\n" <> toS (fromMaybe "" e)
prettyUsageError e = show $ JSON.encode e
instance JSON.ToJSON P.UsageError where
toJSON (P.ConnectionError e) = JSON.object [
"code" .= ("" :: Text),