1#[derive(Debug)]
6#[non_exhaustive]
7pub enum Error {
8 Notify(notify::Error),
10 Vcs(vcs_core::Error),
15 Io(std::io::Error),
17}
18
19impl std::fmt::Display for Error {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 match self {
22 Error::Notify(e) => write!(f, "filesystem watch failed: {e}"),
23 Error::Vcs(e) => write!(f, "{e}"),
24 Error::Io(e) => write!(f, "{e}"),
25 }
26 }
27}
28
29impl std::error::Error for Error {
30 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
31 match self {
32 Error::Notify(e) => Some(e),
33 Error::Vcs(e) => Some(e),
34 Error::Io(e) => Some(e),
35 }
36 }
37}
38
39impl From<notify::Error> for Error {
40 fn from(e: notify::Error) -> Self {
41 Error::Notify(e)
42 }
43}
44
45impl From<vcs_core::Error> for Error {
46 fn from(e: vcs_core::Error) -> Self {
47 Error::Vcs(e)
48 }
49}
50
51impl From<std::io::Error> for Error {
52 fn from(e: std::io::Error) -> Self {
53 Error::Io(e)
54 }
55}
56
57pub type Result<T> = std::result::Result<T, Error>;