Skip to content

Commit 71b9963

Browse files
committed
Improve error handling in project discovery functions
Add proper warning logging for errors in get_current_project_root() and find_targets_for_current_project() functions to help diagnose issues when automatic connection fails to locate project directories or sockets.
1 parent 4d5016a commit 71b9963

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/server/core.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ fn get_current_project_root() -> String {
142142

143143
// Fallback to current working directory
144144
std::env::current_dir()
145-
.unwrap_or_else(|_| std::path::PathBuf::from("."))
145+
.unwrap_or_else(|err| {
146+
warn!("Failed to get current working directory: {}", err);
147+
std::path::PathBuf::from("<unknown project root>")
148+
})
146149
.to_string_lossy()
147150
.to_string()
148151
}
@@ -167,7 +170,13 @@ pub fn find_targets_for_current_project() -> Vec<String> {
167170
.filter_map(|entry| entry.ok())
168171
.map(|path| path.to_string_lossy().to_string())
169172
.collect(),
170-
Err(_) => Vec::new(),
173+
Err(e) => {
174+
warn!(
175+
"Glob error while searching for Neovim sockets with pattern '{}': {}",
176+
pattern, e
177+
);
178+
Vec::new()
179+
}
171180
}
172181
}
173182

0 commit comments

Comments
 (0)