fix: [Splash_Manager errors] catch invalid response

pull/569/head
Terrtia 2021-06-15 17:25:51 +02:00
parent 154558468f
commit 759ec73f84
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
1 changed files with 11 additions and 6 deletions

View File

@ -892,12 +892,17 @@ def ping_splash_manager():
update_splash_manager_connection_status(True) update_splash_manager_connection_status(True)
return True return True
else: else:
res = req.json() try:
if 'reason' in res: res = req.json()
req_error = {'status_code': req.status_code, 'error': res['reason']} if 'reason' in res:
else: req_error = {'status_code': req.status_code, 'error': res['reason']}
print(req.json()) else:
req_error = {'status_code': req.status_code, 'error': json.dumps(req.json())} 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) update_splash_manager_connection_status(False, req_error=req_error)
return False return False
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError: