diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-09-25 20:02:14 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-09-25 20:05:03 +0200 |
commit | 42f6aed731874d937d6f8c9f9c9a6b64d59852d8 (patch) | |
tree | e024a6811b3e3bac7c4524adc5a220fb65266474 /qa/rpc-tests | |
parent | 37871f216e0d9463f456b8b014b80cc064011351 (diff) | |
download | bitcoin-42f6aed731874d937d6f8c9f9c9a6b64d59852d8.tar.xz |
tests: Add exception error message for JSONRPCException
This improves error reporting if `JSONRPCException` is not specifically caught
and ends up in Python's default backtrace handler.
Before:
```
Traceback (most recent call last):
File "/.../projects/bitcoin/bitcoin/qa/rpc-tests/test_framework/authproxy.py", line 153, in __call__
raise JSONRPCException(response['error'])
test_framework.authproxy.JSONRPCException
```
After:
```
Traceback (most recent call last):
File "/.../projects/bitcoin/bitcoin/qa/rpc-tests/test_framework/authproxy.py", line 152, in __call__
raise JSONRPCException(response['error'])
test_framework.authproxy.JSONRPCException: Unknown named parameter random (-8)
```
Diffstat (limited to 'qa/rpc-tests')
-rw-r--r-- | qa/rpc-tests/test_framework/authproxy.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/qa/rpc-tests/test_framework/authproxy.py b/qa/rpc-tests/test_framework/authproxy.py index d095a56ce7..f5e0be20d1 100644 --- a/qa/rpc-tests/test_framework/authproxy.py +++ b/qa/rpc-tests/test_framework/authproxy.py @@ -55,7 +55,11 @@ log = logging.getLogger("BitcoinRPC") class JSONRPCException(Exception): def __init__(self, rpc_error): - Exception.__init__(self) + try: + errmsg = '%(message)s (%(code)i)' % rpc_error + except (KeyError, TypeError): + errmsg = '' + Exception.__init__(self, errmsg) self.error = rpc_error |