[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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user