From 974b74649a3e525bc3fd809501c98716d11021bd Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Mon, 11 Apr 2022 11:47:59 +0200 Subject: Handle ogServer connection error on login On connection error show a (toast) message warning the user. Otherwise, users see Werkzeug debug page. --- ogcp/views.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ogcp/views.py b/ogcp/views.py index ffd5ebf..938710d 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -232,7 +232,13 @@ def index(): if not current_user.is_authenticated: return redirect(url_for('login')) - clients = get_clients() + try: + clients = get_clients() + except requests.exceptions.RequestException as err: + flash(_('ogServer connection failed: {}.').format(err), + category='error') + logout_user() + return redirect(url_for('index')) images_response = g.server.get('/images') images = images_response.json()['images'] images.sort(key=image_modified_date_from_str, reverse=True) -- cgit v1.2.3-18-g5258