Skip to content

Commit 557c615

Browse files
committed
- Program will now exit if an error occurs while trying to load symbols
1 parent dcf413a commit 557c615

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

NSE_Option_Chain_Analyzer.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# noinspection PyAttributeOutsideInit
2828
class Nse:
2929
version: str = '5.2'
30-
beta: Tuple[bool, int] = (True, 12)
30+
beta: Tuple[bool, int] = (True, 13)
3131

3232
def __init__(self, window: Tk) -> None:
3333
self.intervals: List[int] = [1, 2, 3, 5, 10, 15]
@@ -76,9 +76,17 @@ def __init__(self, window: Tk) -> None:
7676
self.login_win(window)
7777

7878
def get_symbols(self) -> None:
79-
symbols_information: requests.Response = requests.get(self.url_symbols, headers=self.headers)
79+
try:
80+
symbols_information: requests.Response = requests.get(self.url_symbols, headers=self.headers)
81+
except Exception as err:
82+
print(err, sys.exc_info()[0], "19")
83+
sys.exit()
8084
symbols_information_soup: bs4.BeautifulSoup = bs4.BeautifulSoup(symbols_information.content, "html.parser")
81-
symbols_table: bs4.element.Tag = symbols_information_soup.findChildren('table')[0]
85+
try:
86+
symbols_table: bs4.element.Tag = symbols_information_soup.findChildren('table')[0]
87+
except IndexError as err:
88+
print(err, sys.exc_info()[0], "20")
89+
sys.exit()
8290
symbols_table_rows: List[bs4.element.Tag] = list(symbols_table.findChildren(['th', 'tr']))
8391
symbols_table_rows_str: List[str] = ['' for _ in range(len(symbols_table_rows) - 1)]
8492
for column in range(len(symbols_table_rows) - 1):

0 commit comments

Comments
 (0)