fix: [Splash_Manager errors] catch invalid response

This commit is contained in:
Terrtia 2021-06-15 17:19:57 +02:00
parent a17ab90511
commit 2abe5217aa
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0

View file

@ -1055,12 +1055,17 @@ def ping_splash_manager():
update_splash_manager_connection_status(True)
return True
else:
try:
res = req.json()
if 'reason' in res:
req_error = {'status_code': req.status_code, 'error': res['reason']}
else:
print(req.json())
req_error = {'status_code': req.status_code, 'error': json.dumps(req.json())}
except json.decoder.JSONDecodeError:
print(req.status_code)
print(req.headers)
req_error = {'status_code': req.status_code, 'error': 'Invalid response'}
update_splash_manager_connection_status(False, req_error=req_error)
return False
except requests.exceptions.ConnectionError: