From 8dbcac9a9756fc4892d7ce629f1709c9d8cd6909 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Mon, 24 Mar 2025 11:37:14 +0800 Subject: [PATCH] chore(catalog/rest): Add response headers in error for debug Signed-off-by: Xuanwo --- crates/catalog/rest/src/client.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/catalog/rest/src/client.rs b/crates/catalog/rest/src/client.rs index dde75276a9..75cd0beeb1 100644 --- a/crates/catalog/rest/src/client.rs +++ b/crates/catalog/rest/src/client.rs @@ -248,11 +248,14 @@ pub(crate) async fn deserialize_catalog_response( /// TODO: Eventually, this function should return an error response that is custom to the error /// codes that all endpoints share (400, 404, etc.). pub(crate) async fn deserialize_unexpected_catalog_error(response: Response) -> Error { + let (status, headers) = (response.status(), response.headers().clone()); let bytes = match response.bytes().await { Ok(bytes) => bytes, Err(err) => return err.into(), }; Error::new(ErrorKind::Unexpected, "Received unexpected response") + .with_context("status", status.to_string()) + .with_context("headers", format!("{:?}", headers)) .with_context("json", String::from_utf8_lossy(&bytes)) }