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,10 +74,16 @@ class OpenWeather(callbacks.Plugin):
|
||||||
country = matches.group(3)
|
country = matches.group(3)
|
||||||
|
|
||||||
if (country == None or country == 'US'):
|
if (country == None or country == 'US'):
|
||||||
loc = self.geocoding_manager.geocode(city, country='US', state_code
|
loc_arr = self.geocoding_manager.geocode(city, country='US', state_code
|
||||||
= state, limit = 1)[0]
|
= state, limit = 1)
|
||||||
else:
|
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))
|
self.log.info(str(loc))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue