From 7bf88ef767d0bb91597471bc642725b98187d4a2 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Mon, 27 Apr 2026 21:17:06 +0100 Subject: add raise to get_location() and exit in main() --- main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index 31414c3..9b8ea36 100644 --- a/main.py +++ b/main.py @@ -36,8 +36,7 @@ def get_location(address: str) -> tuple[float, float]: geolocator = Nominatim(user_agent="FuelNearMe") result = geolocator.geocode(address) if not isinstance(result, Location): - print("[*] Failed to get location. Please check if the address is valid.") - sys.exit(1) + raise ValueError(f"Failed to get location from address: '{address}") return (result.latitude, result.longitude) @@ -101,7 +100,12 @@ def output_stations(stations: List[Dict[str, Any]]) -> None: def main(): args = parse_args() - location = get_location(args.address) + + try: + location = get_location(args.address) + except ValueError as e: + print(f"[*] {e}") + sys.exit(1) df, last_modified = get_latest_data() print(f"Last modified: {last_modified}") -- cgit v1.2.3