Python requests exception handling
Full error message
How to handle exceptions with python library requests?
For example how to check is PC connected to internet?
When I try
try:
requests.get('http://www.google.com')
except ConnectionError:
# handle the exception
it gives me error name ConnectionError is not definedSolutionsource: stackoverflow \u2197
Assuming you did import requests, you want requests.ConnectionError. ConnectionError is an exception defined by requests. See the API documentation here. Thus the code should be: try: requests.get('http://www.google.com') except requests.ConnectionError: # handle the exception The original link to the Python v2 API documentation from the original answer no longer works.
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/1c88a15822569a844985216747bc4addb307066df95d3943508299ef8dfcb3dbhash \u00b7 1c88a15822569a844985216747bc4addb307066df95d3943508299ef8dfcb3db