fix: handle DataNotLoadedError and session load failures gracefully (…#249
fix: handle DataNotLoadedError and session load failures gracefully (…#249nirvik34 wants to merge 5 commits into
Conversation
HEPNARL
left a comment
There was a problem hiding this comment.
This is not a good long term solution for the problem, and could cause unexpected issues in the future. Major changes are required.
| session.load(telemetry=True, weather=True) | ||
| try: | ||
| session = fastf1.get_session(year, round_number, session_type) | ||
| except Exception as e: |
There was a problem hiding this comment.
Catching all exceptions as a generic exception and potentially ignoring them can cause problems in future. fastf1 provides list of possible thrown exception and they should be treated as needed. If there's no match the the program should exit with fail code no matter what happens.
There was a problem hiding this comment.
I refactored load_session to catch specific fastf1 and requests exceptions instead of using generic ones.
|
can you add some test cases or give specific calls that hit each catch clause for those that are possible to replicate? Just trying to do what the test case tells the problem is doesn't appear to be doing anything and falls as exception somewhere else. |
|
are thes changes fine? |


Closes #245
Problem
When session data fails to load, the app crashes with a raw FastF1
traceback — confusing for users who don't know what
DataNotLoadedErrormeans.Changes
src/f1_data.pyload_session()helperDataNotLoadedError→ session may not exist yet or still processingConnectionError→ tells user to check networkmain.pyexit_on_failure=Falseflag for secondary qualifying data loadBefore vs After
Before:
After:
Testing