From 1723f7e2b9e95a57f5c2db5f7533c5374916c0ae Mon Sep 17 00:00:00 2001 From: Will Li Date: Tue, 23 Jul 2024 12:33:16 -0700 Subject: [PATCH] Add error context on cert validation Summary: Add some additional error context when cert check fails instead of overwriting it. Reason #1 is that our cert check could be wrong, so if it is at least we show the actual error Reason #2 If #1 isn't true it lets us collect some data to see what errors caused by invalid certs would look like, which could be useful Reviewed By: JakobDegen Differential Revision: D59988439 fbshipit-source-id: a2355ea4ac39eaa1f55a431c5fbc951fa63b62f0 --- app/buck2_client_ctx/src/daemon/client/connect.rs | 2 +- app/buck2_file_watcher/src/watchman/core.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/buck2_client_ctx/src/daemon/client/connect.rs b/app/buck2_client_ctx/src/daemon/client/connect.rs index 631a936265570..9e5f272ce1cb4 100644 --- a/app/buck2_client_ctx/src/daemon/client/connect.rs +++ b/app/buck2_client_ctx/src/daemon/client/connect.rs @@ -639,7 +639,7 @@ impl<'a> BuckdConnectOptions<'a> { { Ok(client) => Ok(client.with_subscribers(self.subscribers)), Err(e) => { - handle.await.unwrap()?; + handle.await.unwrap().context("Daemon Failed to Connect")?; self.subscribers.handle_daemon_connection_failure(&e); Err(e.into()) } diff --git a/app/buck2_file_watcher/src/watchman/core.rs b/app/buck2_file_watcher/src/watchman/core.rs index ef169fc1987ed..e2bdb4b73ccad 100644 --- a/app/buck2_file_watcher/src/watchman/core.rs +++ b/app/buck2_file_watcher/src/watchman/core.rs @@ -152,11 +152,11 @@ async fn with_timeout( match tokio::time::timeout(Duration::from_secs(timeout), fut).await { Ok(Ok(res)) => Ok(res), Ok(Err(e)) => { - validate_certs().await?; + validate_certs().await.context("Watchman Request Failed")?; Err(WatchmanClientError::RequestFailed(e).into()) } Err(_) => { - validate_certs().await?; + validate_certs().await.context("Watchman Timed Out")?; Err(WatchmanClientError::Timeout(timeout).into()) } }