mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 02:02:42 +02:00
Merge bitcoin/bitcoin#35385: test: restore JSONRPCException error format
ac09260982test: restore JSONRPCException error format (rkrux) Pull request description: This is a follow-up to PR #34575. ACKs for top commit: maflcko: lgtm ACKac09260982Tree-SHA512: 15979f4e2c07993f283640ebfe570e9f8d3842a23a8118042f5b618273e0da8a01bcabe1ec90b6cc49ebf28e9819d1b4f077ac18f62f681a4d4f58ad8e11bdb1
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
"""Helpful routines for regression testing."""
|
||||
|
||||
from base64 import b64encode
|
||||
from copy import copy
|
||||
from decimal import Decimal
|
||||
from subprocess import CalledProcessError
|
||||
import hashlib
|
||||
@@ -30,10 +31,16 @@ logger = logging.getLogger("TestFramework.utils")
|
||||
|
||||
class JSONRPCException(Exception):
|
||||
def __init__(self, rpc_error, http_status=None):
|
||||
super().__init__(f"{rpc_error} [http_status={http_status}]")
|
||||
self.error = rpc_error
|
||||
self.http_status = http_status
|
||||
|
||||
# throw KeyError if any required fields are missing
|
||||
copied_error = copy(rpc_error)
|
||||
message = copied_error.pop("message")
|
||||
code = copied_error.pop("code")
|
||||
extra = f'{copied_error}' if copied_error else ''
|
||||
super().__init__(f"{message} ({code}) {extra} [http_status={http_status}]")
|
||||
|
||||
# Assert functions
|
||||
##################
|
||||
|
||||
|
||||
Reference in New Issue
Block a user