From faa0bb51c97cf244d8ee6414e4a2852af071f6b0 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 4 Jun 2025 01:30:59 +0300 Subject: [PATCH] Better log canonicalization errors (#32030) Based on https://github.com/zed-industries/zed/issues/18673#issuecomment-2933025951 Adds an anyhow error context with the path used for canonicalization (also, explicitly mention path at the place from the comment). Release Notes: - N/A --- crates/fs/src/fs.rs | 4 +++- crates/worktree/src/worktree.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index 3acc974c98..8bedb90b1a 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -597,7 +597,9 @@ impl Fs for RealFs { } async fn canonicalize(&self, path: &Path) -> Result { - Ok(smol::fs::canonicalize(path).await?) + Ok(smol::fs::canonicalize(path) + .await + .with_context(|| format!("canonicalizing {path:?}"))?) } async fn is_file(&self, path: &Path) -> bool { diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index fe8104e1cd..62ce35789e 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -3948,7 +3948,7 @@ impl BackgroundScanner { let root_canonical_path = match self.fs.canonicalize(root_path.as_path()).await { Ok(path) => SanitizedPath::from(path), Err(err) => { - log::error!("failed to canonicalize root path: {}", err); + log::error!("failed to canonicalize root path {root_path:?}: {err}"); return true; } };