json-rpc-generic 0.2.0.2 → 0.2.1.0
raw patch · 3 files changed
+15/−2 lines, 3 filesdep ~aeson
Dependency ranges changed: aeson
Files
- json-rpc-generic.cabal +1/−1
- src/Data/JsonRpc/Failure.hs +9/−1
- test/Iso.hs +5/−0
json-rpc-generic.cabal view
@@ -1,5 +1,5 @@ name: json-rpc-generic-version: 0.2.0.2+version: 0.2.1.0 synopsis: Generic encoder and decode for JSON-RPC description: This package contains generic encoder and decode for JSON-RPC homepage: http://github.com/khibino/haskell-json-rpc-generic
src/Data/JsonRpc/Failure.hs view
@@ -3,7 +3,7 @@ module Data.JsonRpc.Failure ( Failure (..), Error (..),- ErrorStatus (..), toCode, fromCode,+ ErrorStatus (..), toCode, fromCode, refineStatus, failure, makeError, serverError,@@ -100,6 +100,14 @@ | otherwise = serverError c `mplus` methodError c where c = toInteger c'++refineStatus :: MonadPlus m+ => ErrorStatus+ -> m ErrorStatus+refineStatus e = do+ e' <- fromCode $ toCode e+ guard $ e' == e+ return e makeError :: ErrorStatus -> Maybe Text -> Maybe e -> Error e makeError e = Error e . fromMaybe (defaultMessage e)
test/Iso.hs view
@@ -15,6 +15,10 @@ errorStatusCode s = Error.fromCode (Error.toCode s) == Just s +refineStatus :: ErrorStatus -> Bool+refineStatus s =+ Error.refineStatus s == Just s+ aesonED :: (Eq a, ToJSON a, FromJSON a) => a -> Bool aesonED x = Aeson.decode (Aeson.encode x) == Just x@@ -38,6 +42,7 @@ tests :: [Test] tests = [ qcTest "iso - error status code" errorStatusCode+ , qcTest "iso - refine status" refineStatus ] ++ [ x