Improve error handling
This commit is contained in:
parent
96171ca4e5
commit
171d3123b7
1 changed files with 9 additions and 3 deletions
12
plugin.py
12
plugin.py
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue