mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 11:27:28 -03:00
test: report failure during utf8 response decoding
Useful for debugging issues.
This commit is contained in:
parent
018e5fcc46
commit
a2c45ae548
1 changed files with 6 additions and 1 deletions
|
@ -188,7 +188,12 @@ class AuthServiceProxy():
|
||||||
{'code': -342, 'message': 'non-JSON HTTP response with \'%i %s\' from server' % (http_response.status, http_response.reason)},
|
{'code': -342, 'message': 'non-JSON HTTP response with \'%i %s\' from server' % (http_response.status, http_response.reason)},
|
||||||
http_response.status)
|
http_response.status)
|
||||||
|
|
||||||
responsedata = http_response.read().decode('utf8')
|
data = http_response.read()
|
||||||
|
try:
|
||||||
|
responsedata = data.decode('utf8')
|
||||||
|
except UnicodeDecodeError as e:
|
||||||
|
raise JSONRPCException({
|
||||||
|
'code': -342, 'message': f'Cannot decode response in utf8 format, content: {data}, exception: {e}'})
|
||||||
response = json.loads(responsedata, parse_float=decimal.Decimal)
|
response = json.loads(responsedata, parse_float=decimal.Decimal)
|
||||||
elapsed = time.time() - req_start_time
|
elapsed = time.time() - req_start_time
|
||||||
if "error" in response and response["error"] is None:
|
if "error" in response and response["error"] is None:
|
||||||
|
|
Loading…
Reference in a new issue