diff options
| author | Alex Schofield <git@ajschof.me> | 2026-04-27 21:17:06 +0100 |
|---|---|---|
| committer | Alex Schofield <git@ajschof.me> | 2026-04-27 21:17:06 +0100 |
| commit | 7bf88ef767d0bb91597471bc642725b98187d4a2 (patch) | |
| tree | 1bfddeb4e73195113a18a5beab3cda51277e2c8c /main.py | |
| parent | 220c14af6d1dedcafa6c3b69f69ed0ad8a869bcc (diff) | |
| download | fuelnearme-7bf88ef767d0bb91597471bc642725b98187d4a2.tar.gz fuelnearme-7bf88ef767d0bb91597471bc642725b98187d4a2.zip | |
add raise to get_location() and exit in main()
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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}") |
