[F] Handle errors on sendRequest

This commit is contained in:
Hykilpikonna
2020-11-27 10:03:01 -05:00
parent 80766dc1db
commit 30a7a1866c
+9 -6
View File
@@ -99,9 +99,12 @@ def wrap(string: str):
def sendRequest(req):
response = create(req)
text = response.text
if response.headers['Content-Type'] == 'application/json':
text = dictToString(json.loads(text))
response.close()
return text
try:
response = create(req)
text = response.text
if response.headers['Content-Type'] == 'application/json':
text = dictToString(json.loads(text))
response.close()
return text
except requests.exceptions.ConnectionError as e:
return "Error: ConnectionError!\n" + str(e)