Skip to main content

lfs_core/
error.rs

1/// lfs error type
2#[derive(Debug, snafu::Snafu)]
3#[snafu(visibility(pub(crate)))]
4pub enum Error {
5    #[snafu(display("Couldn't execute {exe}"))]
6    CantExecute { source: std::io::Error, exe: String },
7
8    #[snafu(display("Could not read metadata of file {path:?}"))]
9    CantReadFileMetadata {
10        source: std::io::Error,
11        path: std::path::PathBuf,
12    },
13
14    #[snafu(display("Could not read file {path:?}"))]
15    CantReadFile {
16        source: std::io::Error,
17        path: std::path::PathBuf,
18    },
19
20    #[snafu(display("Could not read dir {path:?}"))]
21    CantReadDir {
22        source: std::io::Error,
23        path: std::path::PathBuf,
24    },
25
26    #[snafu(display("Could not parse mountinfo"))]
27    #[cfg(target_os = "linux")]
28    ParseMountInfo {
29        source: crate::linux::ParseMountInfoError,
30    },
31
32    #[snafu(display("Unexpected format"))]
33    UnexpectedFormat,
34
35    #[snafu(display("Error parsing device id"))]
36    ParseDeviceId,
37
38    #[snafu(display("Failed to call service {service:?}"))]
39    ServiceCallFailed { service: &'static str },
40
41    #[snafu(display("Failed to read {key:?}"))]
42    MissingValue { key: &'static str },
43
44    #[cfg(windows)]
45    #[snafu(display("Windows API call failed: {api}"))]
46    WindowsApiError {
47        source: windows::core::Error,
48        api: String,
49    },
50}