Improve error handling.
This commit is contained in:
parent
16eded172d
commit
2e83846028
9
macli.py
9
macli.py
@ -76,8 +76,11 @@ def request(url):
|
||||
return urllib.request.urlopen(req)
|
||||
|
||||
|
||||
def show_error(e):
|
||||
print("\x1b[41;37m{}\x1b[0m")
|
||||
def show_error(e, href=None):
|
||||
print("\r\x1b[K\x1b[41;37m{}\x1b[0m".format(e))
|
||||
if href is not None:
|
||||
print("Url: {}". format(href))
|
||||
|
||||
|
||||
|
||||
def archive(content, base_url, selector, directory, attribute, progbar):
|
||||
@ -102,7 +105,7 @@ def archive(content, base_url, selector, directory, attribute, progbar):
|
||||
try:
|
||||
content = request(href).read()
|
||||
except Exception as e:
|
||||
show_error(e)
|
||||
show_error(e, href)
|
||||
continue
|
||||
|
||||
with open(path, 'wb') as f:
|
||||
|
Loading…
Reference in New Issue
Block a user