jkj
This commit is contained in:
@@ -244,6 +244,8 @@ class HTTPClient:
|
||||
self,
|
||||
method: str,
|
||||
url: str,
|
||||
raise_for_status: bool = True,
|
||||
log_http_errors: bool = True,
|
||||
**kwargs
|
||||
) -> httpx.Response:
|
||||
"""
|
||||
@@ -273,7 +275,8 @@ class HTTPClient:
|
||||
for attempt in range(self.retries):
|
||||
try:
|
||||
response = self._client.request(method, url, **kwargs)
|
||||
response.raise_for_status()
|
||||
if raise_for_status:
|
||||
response.raise_for_status()
|
||||
return response
|
||||
except httpx.TimeoutException as e:
|
||||
last_exception = e
|
||||
@@ -287,7 +290,8 @@ class HTTPClient:
|
||||
response_text = e.response.text[:500]
|
||||
except:
|
||||
response_text = "<unable to read response>"
|
||||
logger.error(f"HTTP {e.response.status_code} from {url}: {response_text}")
|
||||
if log_http_errors:
|
||||
logger.error(f"HTTP {e.response.status_code} from {url}: {response_text}")
|
||||
raise
|
||||
last_exception = e
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user