From bf754b1859cafc765fde9f8341a9b69bc49904ba Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Thu, 11 Nov 2010 00:17:40 +0100 Subject: [PATCH] correctly handle errors --- weboob/applications/wetboobs/wetboobs.py | 26 ++++++------------------ weboob/backends/yahoo/backend.py | 2 +- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/weboob/applications/wetboobs/wetboobs.py b/weboob/applications/wetboobs/wetboobs.py index 7574cf1b..f3ed1fcf 100644 --- a/weboob/applications/wetboobs/wetboobs.py +++ b/weboob/applications/wetboobs/wetboobs.py @@ -48,16 +48,9 @@ class WetBoobs(ReplApplication): Get current weather. """ - try: - for backend, current in self.do('get_current', city): - self.format(current) - self.flush() - except CallErrors, e: - for error in e: - if isinstance(error, CityNotFound): - print >>sys.stderr, 'City "%s" not found' % city - else: - raise error + for backend, current in self.do('get_current', city): + self.format(current) + self.flush() def do_forecasts(self, city): """ @@ -65,13 +58,6 @@ class WetBoobs(ReplApplication): Get forecasts. """ - try: - for backend, forecast in self.do('iter_forecast', city): - self.format(forecast) - self.flush() - except CallErrors, e: - for error in e: - if isinstance(error, CityNotFound): - print >>sys.stderr, 'City "%s" not found' % city - else: - raise error + for backend, forecast in self.do('iter_forecast', city): + self.format(forecast) + self.flush() diff --git a/weboob/backends/yahoo/backend.py b/weboob/backends/yahoo/backend.py index af9369b1..b683db43 100644 --- a/weboob/backends/yahoo/backend.py +++ b/weboob/backends/yahoo/backend.py @@ -46,7 +46,7 @@ class YahooBackend(BaseBackend, ICapWeather): dom = minidom.parse(handler) handler.close() if not dom.getElementsByTagName('yweather:condition'): - raise CityNotFound() + raise CityNotFound('City not found: %s' % city_id) return dom