Skip to content

Commit

Permalink
feat: improve error handling for getting the latest downloaded TCX file
Browse files Browse the repository at this point in the history
Improve the error handling in the get_latest_download() function to handle the case when no TCX file is found in the Downloads folder. Instead of raising a FileNotFoundError, the function now prompts the user to manually provide the file path. If an error occurs while getting the file path, a ValueError is raised.

This commit addresses the issue of the program crashing when no TCX file is found, providing a more user-friendly experience.
  • Loading branch information
Lucs1590 committed Sep 27, 2024
1 parent 57b5f40 commit 3ed9138
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ def get_latest_download() -> str:
return latest_file
else:
logger.error("No TCX file found in the Downloads folder.")
raise FileNotFoundError("No TCX file found in the Downloads folder.")
try:
latest_file = ask_file_path("Download")
return latest_file
except Exception as err:
logger.error("Failed to get the file path.")
raise ValueError("Error getting the file path") from err


def ask_file_path(file_location) -> str:
Expand Down

0 comments on commit 3ed9138

Please sign in to comment.