diff options
| author | Alex Schofield <git@ajschof.me> | 2026-05-05 22:22:12 +0100 |
|---|---|---|
| committer | Alex Schofield <git@ajschof.me> | 2026-05-05 22:22:12 +0100 |
| commit | 3e89605d36793f16d35ae81b9ce5ffbc5c1bca2f (patch) | |
| tree | 70a3c6024e516c62b190674765b910c58274b716 /fnme/cli.py | |
| parent | 736e7dabf47b7de949c55907d2d238f954a4c29e (diff) | |
| download | fuelnearme-improvements.tar.gz fuelnearme-improvements.zip | |
improve error handling when fetching dataimprovements
Diffstat (limited to 'fnme/cli.py')
| -rw-r--r-- | fnme/cli.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/fnme/cli.py b/fnme/cli.py index 22d1a86..5437ff0 100644 --- a/fnme/cli.py +++ b/fnme/cli.py @@ -6,7 +6,7 @@ from tabulate import tabulate from fnme.constants import SORT_KV from fnme.data import get_latest_data -from fnme.exceptions import LocationError +from fnme.exceptions import DataFetchError, LocationError from fnme.geo import get_location from fnme.station import process_stations, sort_stations @@ -64,7 +64,17 @@ def main(): print(f"An unexpected error occurred: {e}") sys.exit(1) - df, last_modified = get_latest_data() + try: + df, last_modified = get_latest_data() + except DataFetchError as e: + print(f"Error: {e.message}") + print( + "Check your internet connection or verify that this script can access the cache location." + ) + sys.exit(1) + except Exception as e: + print(f"An unexpected error occurred: {e}") + sys.exit(1) print(f"Last updated: {last_modified}") |
