1use std::path::PathBuf;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum YgrepError {
6 #[error("IO error: {0}")]
7 Io(#[from] std::io::Error),
8
9 #[error("Index error: {0}")]
10 Index(#[from] tantivy::TantivyError),
11
12 #[error("Query parse error: {0}")]
13 QueryParse(#[from] tantivy::query::QueryParserError),
14
15 #[error("Configuration error: {0}")]
16 Config(String),
17
18 #[error("Workspace not found: {0}")]
19 WorkspaceNotFound(PathBuf),
20
21 #[error("Workspace not indexed: {0}")]
22 WorkspaceNotIndexed(PathBuf),
23
24 #[error("Invalid path: {0}")]
25 InvalidPath(PathBuf),
26
27 #[error("Symlink depth exceeded: {0}")]
28 SymlinkDepthExceeded(PathBuf),
29
30 #[error("Circular symlink detected: {0}")]
31 CircularSymlink(PathBuf),
32
33 #[error("Daemon connection failed: {0}")]
34 DaemonConnection(String),
35
36 #[error("Protocol error: {0}")]
37 Protocol(String),
38
39 #[error("Search timeout")]
40 Timeout,
41
42 #[error("File too large: {path} ({size} bytes, max {max} bytes)")]
43 FileTooLarge { path: PathBuf, size: u64, max: u64 },
44
45 #[error("Unsupported file type: {0}")]
46 UnsupportedFileType(String),
47
48 #[error("Index directory error: {0}")]
49 IndexDirectory(#[from] tantivy::directory::error::OpenDirectoryError),
50
51 #[error("Watch error: {0}")]
52 WatchError(String),
53
54 #[error("Search error: {0}")]
55 Search(String),
56}
57
58pub type Result<T> = std::result::Result<T, YgrepError>;