aboutsummaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorAlex Schofield <git@ajschof.me>2026-04-27 21:17:06 +0100
committerAlex Schofield <git@ajschof.me>2026-04-27 21:17:06 +0100
commit7bf88ef767d0bb91597471bc642725b98187d4a2 (patch)
tree1bfddeb4e73195113a18a5beab3cda51277e2c8c /main.py
parent220c14af6d1dedcafa6c3b69f69ed0ad8a869bcc (diff)
downloadfuelnearme-7bf88ef767d0bb91597471bc642725b98187d4a2.tar.gz
fuelnearme-7bf88ef767d0bb91597471bc642725b98187d4a2.zip
add raise to get_location() and exit in main()
Diffstat (limited to 'main.py')
-rw-r--r--main.py10
1 files changed, 7 insertions, 3 deletions
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}")
git.ajschof.me — hosted by ajschofield — powered by cgit