Skip to main content

kbolt_types/
error.rs

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("ambiguous space: collection '{collection}' exists in spaces: {spaces:?}")]
26    AmbiguousSpace {
27        collection: String,
28        spaces: Vec<String>,
29    },
30
31    #[error("space already exists: {name}")]
32    SpaceAlreadyExists { name: String },
33
34    #[error("collection already exists: {name} (in space {space})")]
35    CollectionAlreadyExists { name: String, space: String },
36
37    #[error("no active space: use --space, set KBOLT_SPACE, or configure a default")]
38    NoActiveSpace,
39
40    #[error("file not found: {0}")]
41    FileNotFound(PathBuf),
42
43    #[error("file deleted since indexing: {0}. Run `kbolt update` to refresh.")]
44    FileDeleted(PathBuf),
45
46    #[error("model not available: {name}")]
47    ModelNotAvailable { name: String },
48
49    #[error("dense state for space '{space}' is inconsistent: {reason}. collection-targeted update cannot repair space-level vector state; run `kbolt --space {space} update`")]
50    SpaceDenseRepairRequired { space: String, reason: String },
51
52    #[error("model download failed: {0}")]
53    ModelDownload(String),
54
55    #[error("inference error: {0}")]
56    Inference(String),
57
58    #[error("config error: {0}")]
59    Config(String),
60
61    #[error("invalid input: {0}")]
62    InvalidInput(String),
63
64    #[error("invalid path: {0}")]
65    InvalidPath(PathBuf),
66
67    #[error("internal error: {0}")]
68    Internal(String),
69
70    #[error("io error: {0}")]
71    Io(#[from] std::io::Error),
72}
73
74pub type Result<T> = std::result::Result<T, KboltError>;