1use std::path::PathBuf;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
8pub enum Error {
9 #[error("directory does not exist: {0}")]
11 DirectoryNotFound(PathBuf),
12
13 #[error("path is not a directory: {0}")]
15 NotADirectory(PathBuf),
16
17 #[error("failed to read file: {path}")]
19 ReadFile {
20 path: PathBuf,
21 #[source]
22 source: std::io::Error,
23 },
24
25 #[error("failed to delete file: {path}")]
27 DeleteFile {
28 path: PathBuf,
29 #[source]
30 source: std::io::Error,
31 },
32
33 #[error("failed to move file from {from} to {to}")]
35 MoveFile {
36 from: PathBuf,
37 to: PathBuf,
38 #[source]
39 source: std::io::Error,
40 },
41
42 #[error("failed to create directory: {path}")]
44 CreateDirectory {
45 path: PathBuf,
46 #[source]
47 source: std::io::Error,
48 },
49
50 #[error("failed to canonicalize path: {path}")]
52 CanonicalizePath {
53 path: PathBuf,
54 #[source]
55 source: std::io::Error,
56 },
57
58 #[error("failed to move to recycle bin: {path}")]
60 RecycleFile {
61 path: PathBuf,
62 #[source]
63 source: trash::Error,
64 },
65
66 #[error("invalid regex pattern")]
68 InvalidRegex(#[from] regex::Error),
69}
70
71pub type Result<T> = std::result::Result<T, Error>;