From 82a64a3300d97e54d808ee23177ca17d7834c2dc Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Thu, 21 Nov 2024 11:36:08 -0800 Subject: [PATCH] Failing to send diagnostics should not fail the install (#1308) --- src/diagnostics.rs | 9 ++++++++- src/plan.rs | 14 +++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/diagnostics.rs b/src/diagnostics.rs index dbd86c8c7..9c4e10804 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -163,7 +163,14 @@ impl DiagnosticData { } #[tracing::instrument(level = "debug", skip_all)] - pub async fn send( + pub async fn send(self, action: DiagnosticAction, status: DiagnosticStatus) { + if let Err(e) = self.send_impl(action, status).await { + tracing::debug!(?e, "Failed to send diagnostics"); + } + } + + #[tracing::instrument(level = "debug", skip_all)] + async fn send_impl( self, action: DiagnosticAction, status: DiagnosticStatus, diff --git a/src/plan.rs b/src/plan.rs index 2287a720a..4ca21c6cc 100644 --- a/src/plan.rs +++ b/src/plan.rs @@ -188,7 +188,7 @@ impl InstallPlan { crate::diagnostics::DiagnosticAction::Install, crate::diagnostics::DiagnosticStatus::Cancelled, ) - .await?; + .await; } return Err(NixInstallerError::Cancelled); @@ -210,7 +210,7 @@ impl InstallPlan { crate::diagnostics::DiagnosticAction::Install, crate::diagnostics::DiagnosticStatus::Failure, ) - .await?; + .await; } return Err(err); @@ -232,7 +232,7 @@ impl InstallPlan { crate::diagnostics::DiagnosticAction::Install, crate::diagnostics::DiagnosticStatus::Failure, ) - .await?; + .await; } tracing::warn!("{err:?}") @@ -245,7 +245,7 @@ impl InstallPlan { crate::diagnostics::DiagnosticAction::Install, crate::diagnostics::DiagnosticStatus::Success, ) - .await?; + .await; } } @@ -360,7 +360,7 @@ impl InstallPlan { crate::diagnostics::DiagnosticAction::Uninstall, crate::diagnostics::DiagnosticStatus::Cancelled, ) - .await?; + .await; } return Err(NixInstallerError::Cancelled); } @@ -381,7 +381,7 @@ impl InstallPlan { crate::diagnostics::DiagnosticAction::Uninstall, crate::diagnostics::DiagnosticStatus::Success, ) - .await?; + .await; } Ok(()) @@ -396,7 +396,7 @@ impl InstallPlan { crate::diagnostics::DiagnosticAction::Uninstall, crate::diagnostics::DiagnosticStatus::Failure, ) - .await?; + .await; } Err(error)