From 30a7a1866cf8f1283b194e5b47b0198a965ada9e Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Fri, 27 Nov 2020 10:03:01 -0500 Subject: [PATCH] [F] Handle errors on sendRequest --- src/utils.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/utils.py b/src/utils.py index 1e3b52c..a2be935 100644 --- a/src/utils.py +++ b/src/utils.py @@ -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)