[pgAdmin][RM4564] JS errors in the Query Tool are caught as ajax errors

Aditya Toshniwal <[email protected]>
Newsgroups gmane.comp.db.postgresql.pgadmin.devel
Message-ID <CAM9w-_mh7mCri7bsoZjP54wvR=BJb5GtPi3CUGE_18f6qg72WA@mail.gmail.com>
Hi Hackers,

Attached is the patch to throw JS errors to browser consoles. JS errors
after execute are now caught by axios catch which shows a false message -
"Not connected to the server or the connection to the server has been
closed."
This will help is debugging in case of JS erors.

Kindly review.

-- 
Thanks and Regards,
Aditya Toshniwal
Sr. Software Engineer | EnterpriseDB India | Pune
"Don't Complain about Heat, Plant a TREE"
RM4564.patch (application/octet-stream, 1.7 KB)
diff --git a/web/pgadmin/static/js/sqleditor/execute_query.js b/web/pgadmin/static/js/sqleditor/execute_query.js
index b8baa410d..4734e7d4a 100644
--- a/web/pgadmin/static/js/sqleditor/execute_query.js
+++ b/web/pgadmin/static/js/sqleditor/execute_query.js
@@ -168,22 +168,28 @@ class ExecuteQuery {
           self.enableSQLEditorButtons();
         }
 
-        if (ExecuteQuery.wasConnectionLostToPythonServer(error.response)) {
-          self.handleConnectionToServerLost();
-          return;
-        }
-
-        const errorData = error.response.data;
+        if(error.response) {
+          if(ExecuteQuery.wasConnectionLostToPythonServer(error.response)) {
+            self.handleConnectionToServerLost();
+            return;
+          }
+          const errorData = error.response.data;
 
-        if (self.userManagement.isPgaLoginRequired(errorData)) {
-          return self.userManagement.pgaLogin();
-        }
+          if (self.userManagement.isPgaLoginRequired(errorData)) {
+            return self.userManagement.pgaLogin();
+          }
 
-        let msg = ExecuteQuery.extractErrorMessage(errorData);
+          let msg = ExecuteQuery.extractErrorMessage(errorData);
 
-        self.sqlServerObject.update_msg_history(false, msg);
-        // Highlight the error in the sql panel
-        self.sqlServerObject._highlight_error(msg);
+          self.sqlServerObject.update_msg_history(false, msg);
+          // Highlight the error in the sql panel
+          self.sqlServerObject._highlight_error(msg);
+        } else if(error.request) {
+          self.handleConnectionToServerLost();
+          return;
+        } else {
+          console.error(error);
+        }
       });
   }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.