diff --git a/backend/src/middlewares/http_client.rs b/backend/src/middlewares/http_client.rs index d84e1ad..30484e2 100644 --- a/backend/src/middlewares/http_client.rs +++ b/backend/src/middlewares/http_client.rs @@ -49,7 +49,8 @@ pub async fn execute_http(req: HttpRequest, opts: HttpClientOptions) -> Result Result r, + Err(e) => { + if e.is_timeout() { + let hint = match opts.timeout_ms { + Some(ms) => format!("http timeout: request {} timed out after {}ms", req.url, ms), + None => format!("http timeout: request {} timed out", req.url), + }; + return Err(anyhow::Error::new(e).context(hint)); + } + return Err(e.into()); + } + }; let status = resp.status().as_u16(); let headers_out: Map = resp .headers() @@ -93,7 +107,20 @@ pub async fn execute_http(req: HttpRequest, opts: HttpClientOptions) -> Result t, + Err(e) => { + if e.is_timeout() { + let hint = match opts.timeout_ms { + Some(ms) => format!("http timeout: reading body from {} timed out after {}ms", req.url, ms), + None => format!("http timeout: reading body from {} timed out", req.url), + }; + return Err(anyhow::Error::new(e).context(hint)); + } + return Err(e.into()); + } + }; let parsed_body: Value = serde_json::from_str(&text).unwrap_or_else(|_| Value::String(text)); Ok(HttpResponse {