handle case where btcpay server does not return JSON
This commit is contained in:
parent
0dff3bad07
commit
4f3c0e41aa
@ -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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user