I'm getting a 403 error from a request I'm making (which is fine that's not the issue). However, I can't seem to catch an except and properly handle the error. My code just moves on like nothing went wrong and is causing other issues. Code
try:
verify = True if os.environ.get('environment', 'dev') != 'dev' else False
response = requests.post(url, headers=headers, data=payload, verify=verify)
return response.content
except requests.HTTPError as e:
print('Error', e)
return None
except requests.exceptions.RequestException as e:
print("Connection refused", e)
return None
except Exception as e:
print("Internal error", e)
return None
Is there something else I can try?