James McCool commited on
Commit
7f07fe7
·
1 Parent(s): d57d310

Add error handling for contest retrieval in app.py

Browse files

- Implemented a try-except block around the contest name retrieval function to handle cases where no contests are found for the selected sport and game type.
- Added an error message to inform users when no contests are available, improving user experience and application robustness.

Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -85,7 +85,11 @@ with tab1:
85
  with sport_options:
86
  sport_select = st.selectbox("Select Sport", ['MLB', 'MMA', 'GOLF', 'NBA', 'NHL'], key='sport_select')
87
  type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'], key='type_var')
88
- contest_names, curr_info = grab_contest_names(db, sport_select, type_var)
 
 
 
 
89
 
90
  with date_options:
91
  date_list = curr_info['Date'].sort_values(ascending=False).unique()
 
85
  with sport_options:
86
  sport_select = st.selectbox("Select Sport", ['MLB', 'MMA', 'GOLF', 'NBA', 'NHL'], key='sport_select')
87
  type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'], key='type_var')
88
+ try:
89
+ contest_names, curr_info = grab_contest_names(db, sport_select, type_var)
90
+ except:
91
+ st.error("No contests found for this sport, type, and date range")
92
+ st.stop()
93
 
94
  with date_options:
95
  date_list = curr_info['Date'].sort_values(ascending=False).unique()