Improve error handling

This commit is contained in:
Darren VanBuren 2025-04-13 07:22:58 -05:00
parent 96171ca4e5
commit 171d3123b7

View file

@ -74,11 +74,17 @@ class OpenWeather(callbacks.Plugin):
country = matches.group(3)
if (country == None or country == 'US'):
loc = self.geocoding_manager.geocode(city, country='US', state_code
= state, limit = 1)[0]
loc_arr = self.geocoding_manager.geocode(city, country='US', state_code
= state, limit = 1)
else:
loc = self.geocoding_manager.geocode(city, country, limit = 1)[0]
loc_arr = self.geocoding_manager.geocode(city, country, limit = 1)
if len(loc_arr) == 0:
irc.error(f'Could not find location with city {city}, state {state}, country {country}',
Raise=True)
loc = loc_arr[0]
self.log.info(str(loc))
one_call = self.weather_manager.one_call(lat=loc.lat, lon=loc.lon,