From 920934759f4f608e6b707328e3306099c12f48e1 Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Tue, 5 Jun 2018 11:57:56 +0100 Subject: [PATCH] Handle a potential error case in the connection status monitoring. When you disconnect the server with an open sqleditor tab, exception occurs at the back end. Also, after connecting server, the sqleditor is not able to connect back because of the exception. --- web/pgadmin/tools/sqleditor/__init__.py | 29 +++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index 013e4dc66..a9460dd7e 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -1480,19 +1480,24 @@ def query_tool_status(trans_id): if conn and trans_obj and session_obj: status = conn.transaction_status() - # Check for the asynchronous notifies statements. - conn.check_notifies(True) - notifies = conn.get_notifies() + if status is not None: + # Check for the asynchronous notifies statements. + conn.check_notifies(True) + notifies = conn.get_notifies() - return make_json_response( - data={ - 'status': status, - 'message': gettext( - CONNECTION_STATUS_MESSAGE_MAPPING.get(status), - ), - 'notifies': notifies - } - ) + return make_json_response( + data={ + 'status': status, + 'message': gettext( + CONNECTION_STATUS_MESSAGE_MAPPING.get(status), + ), + 'notifies': notifies + } + ) + else: + return internal_server_error( + errormsg=gettext("Transaction status check failed.") + ) else: return internal_server_error( errormsg=gettext("Transaction status check failed.")