Raise HTTP errors
This commit is contained in:
parent
cd1f0a2ae3
commit
7db5a29081
1 changed files with 5 additions and 2 deletions
|
|
@ -82,7 +82,10 @@ class APIClient(BaseModel):
|
|||
|
||||
# Make the API request and handle potential exceptions
|
||||
try:
|
||||
response = requests.request(method.upper(), url, json=data, headers=headers, timeout=20)
|
||||
with requests.Session() as session:
|
||||
session.headers.update(headers)
|
||||
response = session.request(method.upper(), url, json=data, headers=headers, timeout=20)
|
||||
response.raise_for_status() # Raise an exception for HTTP errors
|
||||
return_json = response.json()
|
||||
except requests.exceptions.RequestException as e:
|
||||
raise ConnectionError(f"An error occurred while making the request: {e}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue