From 211111b8048dad959a510150d80277bd9b3d0e25 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 12 Feb 2026 16:44:36 +0100 Subject: [PATCH] test: Avoid empty errmsg in JSONRPCException It is unclear why the fallback should be an empty message, when it is better to include all rpc_error details that are available. Also, include the http status. This allows to revert commit 6354b4fd7fe819eb13274b212e426a7d10ca75d3, because it is no longer needed. --- test/functional/test_framework/authproxy.py | 6 +----- test/functional/test_framework/test_framework.py | 7 +++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py index 9b2fc0f7f9e..2d2c42b38bb 100644 --- a/test/functional/test_framework/authproxy.py +++ b/test/functional/test_framework/authproxy.py @@ -51,11 +51,7 @@ log = logging.getLogger("BitcoinRPC") class JSONRPCException(Exception): def __init__(self, rpc_error, http_status=None): - try: - errmsg = '%(message)s (%(code)i)' % rpc_error - except (KeyError, TypeError): - errmsg = '' - super().__init__(errmsg) + super().__init__(f"{rpc_error} [http_status={http_status}]") self.error = rpc_error self.http_status = http_status diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 3ab351aef4a..7970da52595 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -147,11 +147,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): except subprocess.CalledProcessError as e: self.log.exception(f"Called Process failed with stdout='{e.stdout}'; stderr='{e.stderr}';") self.success = TestStatus.FAILED - except JSONRPCException as e: - self.log.exception(f"Failure during setup: error={e.error}, http_status={e.http_status}") - self.success = TestStatus.FAILED except BaseException: - self.log.exception("Unexpected exception") + # The `exception` log will add the exception info to the message. + # https://docs.python.org/3/library/logging.html#logging.exception + self.log.exception("Unexpected exception:") self.success = TestStatus.FAILED finally: exit_code = self.shutdown()