From ebd89d35cc4b8b87161ad13110bb323676f8383c Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Mon, 25 Oct 2010 18:23:25 -0500 Subject: [PATCH] (hopefully) properly catch/log URLError, IndexError --- modules/Weather.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/Weather.py b/modules/Weather.py index b38c335..aa662e1 100644 --- a/modules/Weather.py +++ b/modules/Weather.py @@ -20,6 +20,8 @@ along with this program. If not, see . 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;