From 6279b78b801ca3e7822cbdde9b4055dabae2f146 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 08:31:08 +0000 Subject: [PATCH] refactor(watcher): replace panic with error logging - Replace panic(err) with color.Errorf in walkSingleDirectory - Replace panic("Error touching file" + path) with color.Errorf and return false in isFileChanged - Improves application robustness by preventing crashes on filesystem errors. Co-authored-by: cmuench <211294+cmuench@users.noreply.github.com> --- internal/watcher/watcher.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/watcher/watcher.go b/internal/watcher/watcher.go index 887f5fd..900ae63 100644 --- a/internal/watcher/watcher.go +++ b/internal/watcher/watcher.go @@ -64,7 +64,7 @@ func walkSingleDirectory(we config.WatchEntry) { }) if err != nil { - panic(err) + color.Errorf("Error during directory walk: %v\n", err) } } @@ -98,7 +98,8 @@ func isFileChanged(path string) bool { err := os.Chtimes(path, currentTime, currentModificationTime) if err != nil { - panic("Error touching file" + path) + color.Errorf("Error touching file %s: %v\n", path, err) + return false } fileMap[path] = NodeInfo{