Home > Software engineering >  How to get more verbose exception details using requests module?
How to get more verbose exception details using requests module?

Time:02-10

Python 3.7

I have the following code

try:

    headers = {"content-type": "application/json"}
    json_response = requests.post(someUrl, json=validJson, headers=headers)
    json_response.raise_for_status()

    return something

except Exception as ex:
    raise HTTPException(status_code=500, detail="Exception occurred calling someURL : "   type(ex).__name__)

When this happens all I see is ConnectionError. I know the URL is valid so I want more verbose detail about the exception.

Is there a way to do that?

CodePudding user response:

  •  Tags:  
  • Related