[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): def sendRequest(req):
response = create(req) try:
text = response.text response = create(req)
if response.headers['Content-Type'] == 'application/json': text = response.text
text = dictToString(json.loads(text)) if response.headers['Content-Type'] == 'application/json':
response.close() text = dictToString(json.loads(text))
return text response.close()
return text
except requests.exceptions.ConnectionError as e:
return "Error: ConnectionError!\n" + str(e)