[common] simplify HTTP error messages

[warning] HTTPSConnectionPool(host='domain.tld', port=443): Max retries
exceeded with url: /a.jpg (Caused by NameResolutionError("<urllib3.
connection.HTTPSConnection object at 0x7247fe436ea0>: Failed to resolve
'domain.tld' ([Errno -2] Name or service not known)")) (1/5)

->

[warning] NameResolutionError: Failed to resolve 'domain.tld'
([Errno -2] Name or service not known) (1/5)
This commit is contained in:
Mike Fährmann
2024-12-10 17:11:16 +01:00
parent 86f3f3f763
commit e8826ed3d4
2 changed files with 20 additions and 3 deletions

View File

@@ -144,7 +144,16 @@ class HttpDownloader(DownloaderBase):
proxies=self.proxies,
verify=self.verify,
)
except (ConnectionError, Timeout) as exc:
except ConnectionError as exc:
try:
reason = exc.args[0].reason
cls = reason.__class__.__name__
pre, _, err = str(reason.args[-1]).partition(":")
msg = "{}: {}".format(cls, (err or pre).lstrip())
except Exception:
msg = str(exc)
continue
except Timeout as exc:
msg = str(exc)
continue
except Exception as exc: