Skip to content

Commit

Permalink
Merge pull request jgarzik#43 from nikcub/nikcub-betterexception
Browse files Browse the repository at this point in the history
parse RPC errors into exception object and provide better output handling
  • Loading branch information
Jeff Garzik committed Apr 3, 2015
2 parents cdbecc3 + 68b5f81 commit f607fe7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bitcoinrpc/authproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ def __init__(self, rpc_error):
pass
Exception.__init__(self, *parent_args)
self.error = rpc_error
self.code = rpc_error['code'] if 'code' in rpc_error else None
self.message = rpc_error['message'] if 'message' in rpc_error else None

def __str__(self):
return '%d: %s' % (self.code, self.message)

def __repr__(self):
return '<%s \'%s\'>' % (self.__class__.__name__, self)


def EncodeDecimal(o):
Expand Down

0 comments on commit f607fe7

Please sign in to comment.