Skip to content

Commit 6b6a0ba

Browse files
committed
add broader retry on http client
1 parent 7b08343 commit 6b6a0ba

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

parea/api_client.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ def request(
6565
if e.response.status_code == 422:
6666
# update the error message to include the validation errors
6767
e.args = (f"{e.args[0]}: {e.response.json()}",)
68+
logger.error(
69+
f"HTTP error {e.response.status_code} for {e.request.method} with: {e.args}",
70+
extra={"request_data": data, "request_params": params},
71+
)
6872
raise
6973
except httpx.TimeoutException as e:
7074
logger.error(
@@ -100,6 +104,10 @@ async def request_async(
100104
if e.response.status_code == 422:
101105
# update the error message to include the validation errors
102106
e.args = (f"{e.args[0]}: {e.response.json()}",)
107+
logger.error(
108+
f"HTTP error {e.response.status_code} for {e.request.method} with: {e.args}",
109+
extra={"request_data": data, "request_params": params},
110+
)
103111
raise
104112
except httpx.TimeoutException as e:
105113
logger.error(
@@ -137,6 +145,10 @@ def stream_request(
137145
if e.response.status_code == 422:
138146
# update the error message to include the validation errors
139147
e.args = (f"{e.args[0]}: {e.response.json()}",)
148+
logger.error(
149+
f"HTTP error {e.response.status_code} for {e.request.method} with: {e.args}",
150+
extra={"request_data": data, "request_params": params},
151+
)
140152
raise
141153
except httpx.TimeoutException as e:
142154
logger.error(
@@ -174,6 +186,10 @@ async def stream_request_async(
174186
if e.response.status_code == 422:
175187
# update the error message to include the validation errors
176188
e.args = (f"{e.args[0]}: {e.response.json()}",)
189+
logger.error(
190+
f"HTTP error {e.response.status_code} for {e.request.method} with: {e.args}",
191+
extra={"request_data": data, "request_params": params},
192+
)
177193
raise
178194
except httpx.TimeoutException as e:
179195
logger.error(

0 commit comments

Comments
 (0)