1
2#[derive(thiserror::Error, Debug)]
3pub enum Error {
4 #[error("File system error: {0}")]
5 FileSystemError(#[from] FileSystemError),
6
7 #[error("IO Error: {0}")]
8 Io(#[from] std::io::Error),
9
10 #[error("Operation timed out")]
11 Timeout,
12
13 #[error("Internal error: {0}")]
14 Internal(String),
15}
16
17#[derive(thiserror::Error, Debug)]
18pub enum FileSystemError {
19 #[error("Path not found: {0}")]
20 PathNotFound(std::path::PathBuf),
21
22 #[error("Regex error: {0}")]
23 #[cfg(feature = "regex")]
24 RegexError(#[from] regex::Error),
25
26 #[error("Content not found: {0}")]
27 SearchError(String),
28
29 #[error("File `{name}` closed or inaccessible")]
30 FileClosed {
31 name: String,
32 },
33
34 #[error("UTF-8 error: {0}")]
35 InvalidUtf8(#[from] std::string::FromUtf8Error),
36
37 #[error("Exceeded max recursive depth: {0}")]
38 MaxDepthExceeded(u64),
39
40 #[error("Access denied")]
41 PermissionDenied,
42}
43
44pub type Result<T, E = Error> = std::result::Result<T, E>;
45
46impl From<tokio::time::error::Elapsed> for Error {
47 fn from(_value: tokio::time::error::Elapsed) -> Self {
48 Error::Timeout
49 }
50}