Skip to content

Commit a2c45ae

Browse files
committed
test: report failure during utf8 response decoding
Useful for debugging issues.
1 parent 018e5fc commit a2c45ae

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/functional/test_framework/authproxy.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,12 @@ def _get_response(self):
188188
{'code': -342, 'message': 'non-JSON HTTP response with \'%i %s\' from server' % (http_response.status, http_response.reason)},
189189
http_response.status)
190190

191-
responsedata = http_response.read().decode('utf8')
191+
data = http_response.read()
192+
try:
193+
responsedata = data.decode('utf8')
194+
except UnicodeDecodeError as e:
195+
raise JSONRPCException({
196+
'code': -342, 'message': f'Cannot decode response in utf8 format, content: {data}, exception: {e}'})
192197
response = json.loads(responsedata, parse_float=decimal.Decimal)
193198
elapsed = time.time() - req_start_time
194199
if "error" in response and response["error"] is None:

0 commit comments

Comments
 (0)