unistore_watcher/
error.rs1use crate::deps::PathBuf;
8use thiserror::Error;
9
10#[derive(Debug, Error)]
12pub enum WatcherError {
13 #[error("路径不存在: {0}")]
15 PathNotFound(PathBuf),
16
17 #[error("路径已被监控: {0}")]
19 AlreadyWatched(PathBuf),
20
21 #[error("路径未被监控: {0}")]
23 NotWatched(PathBuf),
24
25 #[error("监控器已关闭")]
27 WatcherClosed,
28
29 #[error("监控错误: {0}")]
31 NotifyError(#[from] notify::Error),
32
33 #[error("事件发送失败")]
35 SendError,
36
37 #[error("监控器初始化失败: {0}")]
39 InitError(String),
40}
41
42impl WatcherError {
43 pub fn is_not_found(&self) -> bool {
45 matches!(self, Self::PathNotFound(_))
46 }
47
48 pub fn is_already_watched(&self) -> bool {
50 matches!(self, Self::AlreadyWatched(_))
51 }
52}