1use std::path::PathBuf;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum KboltError {
7 #[error("database error: {0}")]
8 Database(String),
9
10 #[error("tantivy error: {0}")]
11 Tantivy(String),
12
13 #[error("usearch error: {0}")]
14 USearch(String),
15
16 #[error("space not found: {name}")]
17 SpaceNotFound { name: String },
18
19 #[error("collection not found: {name}")]
20 CollectionNotFound { name: String },
21
22 #[error("document not found: {path}")]
23 DocumentNotFound { path: String },
24
25 #[error("chunk not found: {locator}")]
26 ChunkNotFound { locator: String },
27
28 #[error("ambiguous space: collection '{collection}' exists in spaces: {spaces:?}")]
29 AmbiguousSpace {
30 collection: String,
31 spaces: Vec<String>,
32 },
33
34 #[error("space already exists: {name}")]
35 SpaceAlreadyExists { name: String },
36
37 #[error("collection already exists: {name} (in space {space})")]
38 CollectionAlreadyExists { name: String, space: String },
39
40 #[error("no active space: use --space, set KBOLT_SPACE, or configure a default")]
41 NoActiveSpace,
42
43 #[error("file not found: {0}")]
44 FileNotFound(PathBuf),
45
46 #[error("eval file not found: {0}")]
47 EvalFileNotFound(PathBuf),
48
49 #[error("file deleted since indexing: {0}. Run `kbolt update` to refresh.")]
50 FileDeleted(PathBuf),
51
52 #[error("model not available: {name}")]
53 ModelNotAvailable { name: String },
54
55 #[error("schedule not found: {id}")]
56 ScheduleNotFound { id: String },
57
58 #[error("schedule not found")]
59 ScheduleScopeNotFound,
60
61 #[error("schedule scope matched multiple schedules: {ids:?}")]
62 ScheduleScopeAmbiguous { ids: Vec<String> },
63
64 #[error("invalid schedule interval: {reason}")]
65 InvalidScheduleInterval { reason: String },
66
67 #[error("semantic search unavailable: {reason}")]
68 SemanticUnavailable { reason: String },
69
70 #[error("deep search unavailable: {reason}")]
71 DeepUnavailable { reason: String },
72
73 #[error("dense state for space '{space}' is inconsistent: {reason}. collection-targeted update cannot repair space-level vector state; run `kbolt --space {space} update`")]
74 SpaceDenseRepairRequired { space: String, reason: String },
75
76 #[error("model download failed: {0}")]
77 ModelDownload(String),
78
79 #[error("inference error: {0}")]
80 Inference(String),
81
82 #[error("config error: {0}")]
83 Config(String),
84
85 #[error("invalid input: {0}")]
86 InvalidInput(String),
87
88 #[error("invalid path: {0}")]
89 InvalidPath(PathBuf),
90
91 #[error("internal error: {0}")]
92 Internal(String),
93
94 #[error("io error: {0}")]
95 Io(#[from] std::io::Error),
96}
97
98pub type Result<T> = std::result::Result<T, KboltError>;