This commit is contained in:
nose
2025-12-16 23:23:43 -08:00
parent 9873280f0e
commit 86918f2ae2
46 changed files with 2277 additions and 1347 deletions

View File

@@ -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: