diff --git a/joinmarket/jsonrpc.py b/joinmarket/jsonrpc.py index aefbb246..0fcc8bf9 100644 --- a/joinmarket/jsonrpc.py +++ b/joinmarket/jsonrpc.py @@ -86,14 +86,13 @@ def queryHTTP(self, obj): raise JsonRpcConnectionError( "authentication for JSON-RPC failed") - # All of the codes below are 'fine' from a JSON-RPC point of view. - if response.status not in [200, 404, 500]: - conn.close() - raise JsonRpcConnectionError("unknown error in JSON-RPC") - data = response.read() conn.close() + # All of the codes below are 'fine' from a JSON-RPC point of view. + if response.status not in [200, 404, 500]: + raise JsonRpcConnectionError("unknown error %s in JSON-RPC: %s" % (response.status, data)) + return json.loads(data) except JsonRpcConnectionError as exc: