From 017bd8ffe71279bed6f080e2ef303a232a53a64c Mon Sep 17 00:00:00 2001 From: vishw Date: Sat, 4 Oct 2025 11:03:40 +0530 Subject: [PATCH] Fix scope issue in interactive_login function - Initialize response variable before try block to avoid NameError - Add proper error handling in except block with fallback to exception string - Ensures function returns meaningful error messages instead of crashing --- Connect.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Connect.py b/Connect.py index 5a8be26..88495a6 100644 --- a/Connect.py +++ b/Connect.py @@ -197,6 +197,7 @@ def _login_url(self): def interactive_login(self): """Send the login url to which a user should receive the token.""" + response = None try: params = { "appKey": self.apiKey, @@ -210,7 +211,10 @@ def interactive_login(self): response['result']['isInvestorClient']) return response except Exception as e: - return response['description'] + if response and 'description' in response: + return response['description'] + else: + return str(e) def get_order_book(self, clientID=None): """Request Order book gives states of all the orders placed by an user"""