Simplify exception handling.
This commit is contained in:
parent
1d7410c038
commit
2bdf0d588d
2 changed files with 4 additions and 7 deletions
6
dosage
6
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
|
||||
|
|
|
@ -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))
|
||||
content_type = unquote(self.urlobj.headers.get('content-type', 'application/octet-stream'))
|
||||
content_type = content_type.split(';', 1)[0]
|
||||
if '/' in content_type:
|
||||
|
|
Loading…
Reference in a new issue