Skip to content

Commit 7e1e106

Browse files
valeratradesclaude
andcommitted
wip: add detailed logging for HTTP response failures
Added error logging to capture status, headers, and body content when: - Reading response body fails (timeout/network error) - Handling/parsing response fails 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 721fba9 commit 7e1e106

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

v_exchanges/src/kucoin/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl Exchange for Kucoin {
3131
}
3232

3333
fn set_recv_window(&mut self, _recv_window: std::time::Duration) {
34-
unimplemented!("Kucoin does not support recv_window as a global setting");
34+
tracing::warn!("Kucoin does not support recv_window as a global setting");
3535
}
3636

3737
async fn exchange_info(&self, instrument: Instrument, recv_window: Option<std::time::Duration>) -> ExchangeResult<ExchangeInfo> {

v_exchanges_api_generics/src/http.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@ impl Client {
7575
Ok(mut response) => {
7676
let status = response.status();
7777
let headers = std::mem::take(response.headers_mut());
78-
let body: Bytes = response.bytes().await.map_err(RequestError::ReceiveResponse)?;
78+
debug!(?status, ?headers, "Received response headers");
79+
let body: Bytes = match response.bytes().await {
80+
Ok(b) => b,
81+
Err(e) => {
82+
error!(?status, ?headers, ?e, "Failed to read response body");
83+
return Err(RequestError::ReceiveResponse(e));
84+
}
85+
};
7986
{
8087
let truncated_body = v_utils::utils::truncate_msg(std::str::from_utf8(&body)?.trim());
8188
debug!(truncated_body);
@@ -89,7 +96,10 @@ impl Client {
8996
return Ok(handled);
9097
}
9198
false => {
92-
return handler.handle_response(status, headers, body).map_err(RequestError::HandleResponse);
99+
return handler.handle_response(status, headers.clone(), body.clone()).map_err(|e| {
100+
error!(?status, ?headers, body = ?v_utils::utils::truncate_msg(std::str::from_utf8(&body).unwrap_or("<invalid utf8>")), "Failed to handle response");
101+
RequestError::HandleResponse(e)
102+
});
93103
}
94104
}
95105
}

0 commit comments

Comments
 (0)