Skip to content

Commit 42f6aed

Browse files
committed
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) ```
1 parent 37871f2 commit 42f6aed

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

qa/rpc-tests/test_framework/authproxy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@
5555

5656
class JSONRPCException(Exception):
5757
def __init__(self, rpc_error):
58-
Exception.__init__(self)
58+
try:
59+
errmsg = '%(message)s (%(code)i)' % rpc_error
60+
except (KeyError, TypeError):
61+
errmsg = ''
62+
Exception.__init__(self, errmsg)
5963
self.error = rpc_error
6064

6165

0 commit comments

Comments
 (0)