From 63722bb7a2ab0a4c03a7ac3f432c877b208d5587 Mon Sep 17 00:00:00 2001 From: Lynne Date: Wed, 11 Sep 2019 18:33:02 +1000 Subject: [PATCH] handle connection errors on bot creation page --- webui.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webui.py b/webui.py index 339d4aa..3bbd02f 100644 --- a/webui.py +++ b/webui.py @@ -375,7 +375,13 @@ def bot_create(): session['instance'] = re.match(r"^(?:https?:\/\/)?(.*)", request.form['instance']).group(1) # check for mastodon/pleroma - r = requests.get("https://{}/api/v1/instance".format(session['instance']), timeout=10) + try: + r = requests.get("https://{}/api/v1/instance".format(session['instance']), timeout=10) + except requests.ConnectionError: + session['error'] = "Couldn't connect to https://{}.".format(session['instance']) + except: + session['error'] = "An unknown error occurred while trying to load https://{}".format(session['instance']) + if r.status_code == 200: j = r.json() if "Pleroma" in j['version']: