Revision 0ae9ddc4

b/htools/Ganeti/Rpc.hs
198 198
  | otherwise = Left $ OfflineNodeError node
199 199

  
200 200
-- | Parse a result based on the received HTTP response.
201
rpcResultParse :: (Rpc a b) => a -> String -> ERpcError b
202
rpcResultParse call res =
201
parseHttpResponse :: (Rpc a b) => a -> ERpcError String -> ERpcError b
202
parseHttpResponse _ (Left err) = Left err
203
parseHttpResponse call (Right res) =
203 204
  case J.decode res of
204 205
    J.Error val -> Left $ JsonDecodeError val
205 206
    J.Ok (True, res'') -> rpcResultFill call res''
......
207 208
       J.JSString msg -> Left $ RpcResultError (J.fromJSString msg)
208 209
       _ -> Left . JsonDecodeError $ show (pp_value jerr)
209 210

  
210
-- | Parse the response or propagate the error.
211
parseHttpResponse :: (Rpc a b) => a -> ERpcError String -> ERpcError b
212
parseHttpResponse _ (Left err) = Left err
213
parseHttpResponse call (Right response) = rpcResultParse call response
214

  
215 211
-- | Execute RPC call for a sigle node.
216 212
executeSingleRpcCall :: (Rpc a b) => Node -> a -> IO (Node, ERpcError b)
217 213
executeSingleRpcCall node call = do

Also available in: Unified diff