From 2e838460287b1f5853fef85072bbcb6a10716c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Wed, 15 Dec 2021 20:52:47 +0100 Subject: [PATCH] Improve error handling. --- macli.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/macli.py b/macli.py index 9424aa2..3e2dcd0 100644 --- a/macli.py +++ b/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: