Include JSON content type for errors
This commit is contained in:
+3
-1
@@ -12,11 +12,13 @@ import Data.Aeson ((.=))
|
|||||||
import Data.String.Conversions (cs)
|
import Data.String.Conversions (cs)
|
||||||
import Data.String.Utils(replace)
|
import Data.String.Utils(replace)
|
||||||
import Network.Wai(Response, responseLBS)
|
import Network.Wai(Response, responseLBS)
|
||||||
|
import Network.HTTP.Types.Header
|
||||||
|
|
||||||
type PgError = H.SessionError P.Postgres
|
type PgError = H.SessionError P.Postgres
|
||||||
|
|
||||||
errResponse :: PgError -> Response
|
errResponse :: PgError -> Response
|
||||||
errResponse e = responseLBS (httpStatus e) [] (JSON.encode e)
|
errResponse e = responseLBS (httpStatus e)
|
||||||
|
[(hContentType, "application/json")] (JSON.encode e)
|
||||||
|
|
||||||
instance JSON.ToJSON PgError where
|
instance JSON.ToJSON PgError where
|
||||||
toJSON (H.TxError (P.ErroneousResult c m d h)) = JSON.object [
|
toJSON (H.TxError (P.ErroneousResult c m d h)) = JSON.object [
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ import Control.Monad (replicateM_)
|
|||||||
|
|
||||||
import TestTypes(IncPK(..), CompoundPK(..))
|
import TestTypes(IncPK(..), CompoundPK(..))
|
||||||
|
|
||||||
--import Debug.Trace
|
|
||||||
|
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = afterAll_ resetDb $ around withApp $ do
|
spec = afterAll_ resetDb $ around withApp $ do
|
||||||
describe "Posting new record" $ do
|
describe "Posting new record" $ do
|
||||||
|
|||||||
Reference in New Issue
Block a user