From 2bdf0d588dabd91d30319e8d6221cfb8de837f5a Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Fri, 8 Mar 2013 00:06:50 +0100 Subject: [PATCH] Simplify exception handling. --- dosage | 6 +++--- dosagelib/comic.py | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/dosage b/dosage index 97c7da1e3..a221f34c2 100755 --- a/dosage +++ b/dosage @@ -129,7 +129,7 @@ def displayHelp(comics): try: for scraperobj in getScrapers(comics): displayComicHelp(scraperobj) - except ValueError as msg: + except Exception as msg: out.error(msg) return 1 return 0 @@ -157,7 +157,7 @@ def getComics(options): try: for scraperobj in getScrapers(options.comic, options.basepath, options.adult, options.multimatch): errors += getStrips(scraperobj, options) - except ValueError as msg: + except Exception as msg: out.error(msg) errors += 1 finally: @@ -185,7 +185,7 @@ def getStrips(scraperobj, options): # stop when retrieval skipped an image for one comic strip out.info("Stop retrieval because image file already exists") break - except (ValueError, IOError) as msg: + except Exception as msg: out.error(msg) errors += 1 return errors diff --git a/dosagelib/comic.py b/dosagelib/comic.py index 90bfb1b29..e75bfcbbd 100644 --- a/dosagelib/comic.py +++ b/dosagelib/comic.py @@ -49,10 +49,7 @@ class ComicImage(object): def connect(self): """Connect to host and get meta information.""" - try: - self.urlobj = getImageObject(self.url, self.referrer, self.session) - except IOError as msg: - raise IOError('error retrieving URL %s: %s' % (self.url, msg)) + self.urlobj = getImageObject(self.url, self.referrer, self.session) content_type = unquote(self.urlobj.headers.get('content-type', 'application/octet-stream')) content_type = content_type.split(';', 1)[0] if '/' in content_type: