From 7b2c1bb9f8fb3652675a1871359eb5fee81a82c2 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Fri, 10 Aug 2018 13:51:32 +0100 Subject: [PATCH] Handle connection errors properly in the query tool. Fixes #3528 --- docs/en_US/release_notes_3_3.rst | 1 + web/pgadmin/tools/datagrid/__init__.py | 6 +++++- web/pgadmin/tools/sqleditor/__init__.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/en_US/release_notes_3_3.rst b/docs/en_US/release_notes_3_3.rst index eb8f2ccc1..0ed01af25 100644 --- a/docs/en_US/release_notes_3_3.rst +++ b/docs/en_US/release_notes_3_3.rst @@ -16,3 +16,4 @@ Bug fixes ********* | `Bug #3407 `_ - Fix keyboard shortcuts layout in the preferences panel. +| `Bug #3528 `_ - Handle connection errors properly in the query tool. diff --git a/web/pgadmin/tools/datagrid/__init__.py b/web/pgadmin/tools/datagrid/__init__.py index 04e2a683a..a25a44582 100644 --- a/web/pgadmin/tools/datagrid/__init__.py +++ b/web/pgadmin/tools/datagrid/__init__.py @@ -332,8 +332,12 @@ def initialize_query_tool(sgid, sid, did=None): use_binary_placeholder=True, array_to_string=True) if connect: - conn.connect() + status, msg = conn.connect() + if not status: + app.logger.error(msg) + return internal_server_error(errormsg=str(msg)) except (ConnectionLost, SSHTunnelConnectionLost) as e: + app.logger.error(e) raise except Exception as e: app.logger.error(e) diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index 087c743a7..9d8a256c3 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -307,7 +307,7 @@ def start_query_tool(trans_id): connect = 'connect' in request.args and request.args['connect'] == '1' - return StartRunningQuery(blueprint, current_app).execute( + return StartRunningQuery(blueprint, current_app.logger).execute( sql, trans_id, session, connect )