(hopefully) properly catch/log URLError, IndexError

This commit is contained in:
Brian S. Stephan 2010-10-25 18:23:25 -05:00
parent a45af7a0a7
commit ebd89d35cc
1 changed files with 5 additions and 2 deletions

View File

@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
from extlib import irclib
from extlib import pywapi
from urllib2 import URLError
from Module import Module
class Weather(Module):
@ -38,9 +40,10 @@ class Weather(Module):
weatherstr += " " + city['day_of_week'].encode('utf-8') + ": " + city['condition'].encode('utf-8') + ". High " + city['high'].encode('utf-8') + "°F, Low " + city['low'].encode('utf-8') + "°F."
return self.reply(connection, replypath, unicode(weatherstr, 'utf-8'))
except URLError as e:
return self.reply(connection, replypath, "error connecting to google weather:" + str(e))
except IndexError as e:
print("error in pywapi: " + str(e))
return
return self.reply(connection, replypath, "error in pywapi: " + str(e))
# vi:tabstop=4:expandtab:autoindent
# kate: indent-mode python;indent-width 4;replace-tabs on;