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)
|
return urllib.request.urlopen(req)
|
||||||
|
|
||||||
|
|
||||||
def show_error(e):
|
def show_error(e, href=None):
|
||||||
print("\x1b[41;37m{}\x1b[0m")
|
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):
|
def archive(content, base_url, selector, directory, attribute, progbar):
|
||||||
@ -102,7 +105,7 @@ def archive(content, base_url, selector, directory, attribute, progbar):
|
|||||||
try:
|
try:
|
||||||
content = request(href).read()
|
content = request(href).read()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
show_error(e)
|
show_error(e, href)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
with open(path, 'wb') as f:
|
with open(path, 'wb') as f:
|
||||||
|
Loading…
Reference in New Issue
Block a user