Reputation: 625
I'm trying to make a GET request surrounded by try\catch in case hostname can't be DNS queried or network is failing.
Trying to surround with try\catch seems to not working and an error is raised.
import http.client
try:
conn = http.client.HTTPSConnection("non.existent.url")
conn.request("GET", "/")
except Exception as e:
print(e)
I'm expecting the exception to be caught and printed out but instead, the code will exit with the error:
Exception has occurred: gaierror
[Errno 11001] getaddrinfo failed
Upvotes: 0
Views: 1658
Reputation: 625
Everything is working as intended even on Win10. The issue was that VSCode Debugger has Breakpoint: Raised Error checked. This makes VSCode breakpoint a caught error.
Upvotes: 1