Kennethreitz requests lib? Just use requests.exceptions.RequestException, that should handle every error, if not then report it.
For python urllib IOError and OSError should suffice. At least in py3.
For python urllib IOError and OSError should suffice. At least in py3.
import urllib.request
try:
urllib.request.urlopen('https://wrong.host.badssl.com/')
except (IOError, OSError):
pass
causes: ssl.CertificateError: hostname 'wrong.host.badssl.com' doesn't match either of '*.badssl.com', 'badssl.com'