diff --git a/bitcoinrpc/authproxy.py b/bitcoinrpc/authproxy.py index 3d9eb8c..18c698f 100644 --- a/bitcoinrpc/authproxy.py +++ b/bitcoinrpc/authproxy.py @@ -139,7 +139,7 @@ def __call__(self, *args): response = self._get_response() if response.get('error') is not None: - raise JSONRPCException(response['error']) + raise JSONRPCException(response.get('error')) elif 'result' not in response: raise JSONRPCException({ 'code': -343, 'message': 'missing JSON-RPC result'}) @@ -172,8 +172,8 @@ def batch_(self, rpc_calls): raise JSONRPCException({ 'code': -32700, 'message': 'Parse error'}) for response in responses: - if response['error'] is not None: - raise JSONRPCException(response['error']) + if response.get('error') is not None: + raise JSONRPCException(response.get('error')) elif 'result' not in response: raise JSONRPCException({ 'code': -343, 'message': 'missing JSON-RPC result'}) @@ -194,7 +194,7 @@ def _get_response(self): responsedata = http_response.read().decode('utf8') response = json.loads(responsedata, parse_float=decimal.Decimal) - if "error" in response and response["error"] is None: + if "error" in response and response.get('error') is None: log.debug("<-%s- %s"%(response["id"], json.dumps(response["result"], default=EncodeDecimal))) else: log.debug("<-- "+responsedata)