1use std::path::PathBuf;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
8pub enum FileError {
9 #[error("Failed to open file at {0}")]
11 FileOpen(PathBuf, #[source] std::io::Error),
12 #[error("Failed to read file at {0}")]
13 FileRead(PathBuf, #[source] std::io::Error),
14 #[error("Failed to write file at {0}")]
15 FileWrite(PathBuf, #[source] std::io::Error),
16 #[error("Failed to create file at {0}")]
17 FileCreate(PathBuf, #[source] std::io::Error),
18 #[error("Failed to remove file at {0}")]
19 FileRemove(PathBuf, #[source] std::io::Error),
20 #[error("Failed to copy file from {from} to {to}")]
21 FileCopy {
22 from: PathBuf,
23 to: PathBuf,
24 source: std::io::Error,
25 },
26 #[error("Failed to create temporary file")]
27 TempFile(#[source] std::io::Error),
28 #[error("Failed to read directory at {0}")]
29 DirRead(PathBuf, #[source] std::io::Error),
30 #[error("Failed to create directory at {0}")]
31 DirCreate(PathBuf, #[source] std::io::Error),
32 #[error("Failed to remove directory at {0}")]
33 DirRemove(PathBuf, #[source] std::io::Error),
34 #[error("Failed to rename file {from} to {to}")]
35 Rename {
36 from: PathBuf,
37 to: PathBuf,
38 source: std::io::Error,
39 },
40 #[error("Path {0} has no file name")]
41 NoFileName(PathBuf),
42 #[error("Expected {0} to be a directory, but it was a file")]
43 UnexpectedFile(PathBuf),
44 #[error("Failed to read data")]
45 ReadError(#[source] std::io::Error),
46 #[error("Failed to write data")]
47 WriteError(#[source] std::io::Error),
48 #[error("Failed to canonicalize path {0}")]
49 Canonicalize(PathBuf, #[source] std::io::Error),
50
51 #[error("Failed to lock {0}: not a file or directory")]
53 InvalidLockPath(PathBuf),
54
55 #[error("Directory walk error")]
56 Walkdir(#[from] walkdir::Error),
57}