Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



  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'


and in Python >=3.3, IOError is an alias for OSError.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: