Graceful errors instead of crashing (#1267)

This commit is contained in:
boatbomber
2026-06-01 20:02:39 -07:00
committed by GitHub
parent 85655ca84f
commit 1abf675949
17 changed files with 167 additions and 99 deletions

View File

@@ -17,9 +17,9 @@ pub struct StdBackend {
}
impl StdBackend {
pub fn new() -> StdBackend {
pub fn new() -> io::Result<StdBackend> {
let (notify_tx, notify_rx) = mpsc::channel();
let watcher = watcher(notify_tx, Duration::from_millis(50)).unwrap();
let watcher = watcher(notify_tx, Duration::from_millis(50)).map_err(io::Error::other)?;
let (tx, rx) = crossbeam_channel::unbounded();
@@ -46,11 +46,11 @@ impl StdBackend {
Result::<(), crossbeam_channel::SendError<VfsEvent>>::Ok(())
});
Self {
Ok(Self {
watcher,
watcher_receiver: rx,
watches: HashSet::new(),
}
})
}
}
@@ -134,9 +134,3 @@ impl VfsBackend for StdBackend {
self.watcher.unwatch(path).map_err(io::Error::other)
}
}
impl Default for StdBackend {
fn default() -> Self {
Self::new()
}
}