handle case where btcpay server does not return JSON

This commit is contained in:
forest 2021-12-16 19:13:16 -06:00
parent 0dff3bad07
commit 4f3c0e41aa

View File

@ -51,7 +51,13 @@ class Client:
raise BtcPayArgumentError("Price must be formatted as a float")
def response_error(self, response):
raise BtcPayBtcPayError('%(code)d: %(message)s' % {'code': response.status_code, 'message': response.json()['error']})
error_message = response.text
try:
error_json = json.loads(error_message)
error_message = error_json['error']
except:
pass
raise BtcPayBtcPayError('%(code)d: %(message)s' % {'code': response.status_code, 'message': error_message})
def unsigned_request(self, path, payload=None):
"""