aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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