From f1d4ffd7fa489aca69ad84282761114a2aeea8a2 Mon Sep 17 00:00:00 2001 From: arabian Date: Wed, 28 Jan 2026 21:44:00 +0300 Subject: [PATCH] fix: handle errors when opening a directory in SoundpadGui --- src/gui/mod.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gui/mod.rs b/src/gui/mod.rs index a42bf60..bc93999 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -110,12 +110,18 @@ impl SoundpadGui { pub fn open_dir(&mut self, path: &PathBuf) { self.app_state.current_dir = Some(path.clone()); - self.app_state.files = path - .read_dir() - .unwrap() - .filter_map(|res| res.ok()) - .map(|entry| entry.path()) - .collect(); + match path.read_dir() { + Ok(read_dir) => { + self.app_state.files = read_dir + .filter_map(|res| res.ok()) + .map(|entry| entry.path()) + .collect(); + } + Err(e) => { + eprintln!("Failed to read directory {:?}: {}", path, e); + self.app_state.files.clear(); + } + } } pub fn play_file(&mut self, path: &PathBuf, concurrent: bool) {