I'm doing this:
import requests r = requests.get("http://non-existent-domain.test") And getting
ConnectionError: HTTPConnectionPool(host='non-existent-domain.test', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x10b0170f0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',)) However, if I try to catch it like this:
try: r = requests.get("http://non-existent-domain.test") except ConnectionError: print("ConnectionError") Nothing changes, I still have ConnectionError unhandled. How to catch it properly?