Skip to content
Snippets Groups Projects
Commit 0ae9ddc4 authored by Agata Murawska's avatar Agata Murawska
Browse files

Merge parseHttpResponse with rpcResultParse


parseHttpResponse is such a simple function that we can actually
do the entire unpacking in rpcResultParse.

Signed-off-by: default avatarAgata Murawska <agatamurawska@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 7328a28c
No related branches found
No related tags found
No related merge requests found
......@@ -198,8 +198,9 @@ prepareHttpRequest node call
| otherwise = Left $ OfflineNodeError node
-- | Parse a result based on the received HTTP response.
rpcResultParse :: (Rpc a b) => a -> String -> ERpcError b
rpcResultParse call res =
parseHttpResponse :: (Rpc a b) => a -> ERpcError String -> ERpcError b
parseHttpResponse _ (Left err) = Left err
parseHttpResponse call (Right res) =
case J.decode res of
J.Error val -> Left $ JsonDecodeError val
J.Ok (True, res'') -> rpcResultFill call res''
......@@ -207,11 +208,6 @@ rpcResultParse call res =
J.JSString msg -> Left $ RpcResultError (J.fromJSString msg)
_ -> Left . JsonDecodeError $ show (pp_value jerr)
-- | Parse the response or propagate the error.
parseHttpResponse :: (Rpc a b) => a -> ERpcError String -> ERpcError b
parseHttpResponse _ (Left err) = Left err
parseHttpResponse call (Right response) = rpcResultParse call response
-- | Execute RPC call for a sigle node.
executeSingleRpcCall :: (Rpc a b) => Node -> a -> IO (Node, ERpcError b)
executeSingleRpcCall node call = do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment