Skip to main content

sqlite_knowledge_graph/
error.rs

1//! Error types for sqlite-knowledge-graph.
2
3use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, Error>;
6
7#[derive(Error, Debug)]
8pub enum Error {
9    #[error("SQLite error: {0}")]
10    SQLite(#[from] rusqlite::Error),
11
12    #[error("JSON error: {0}")]
13    Json(#[from] serde_json::Error),
14
15    #[error("IO error: {0}")]
16    Io(#[from] std::io::Error),
17
18    #[error("Entity not found: {0}")]
19    EntityNotFound(i64),
20
21    #[error("Relation not found: {0}")]
22    RelationNotFound(i64),
23
24    #[error("Invalid vector dimension: expected {expected}, got {actual}")]
25    InvalidVectorDimension { expected: usize, actual: usize },
26
27    #[error("Invalid depth: {0}")]
28    InvalidDepth(u32),
29
30    #[error("Invalid weight: {0}")]
31    InvalidWeight(f64),
32
33    #[error("Invalid arity: {0} (minimum 2 entities required)")]
34    InvalidArity(usize),
35
36    #[error("Hyperedge not found: {0}")]
37    HyperedgeNotFound(i64),
38
39    #[error("Version not found: {0}")]
40    VersionNotFound(i64),
41
42    #[error("Duplicate version name: {0}")]
43    DuplicateVersionName(String),
44
45    #[error("Invalid merge: {0}")]
46    InvalidMerge(String),
47
48    #[error("Version limit exceeded: all 64 version slots are in use")]
49    VersionLimitExceeded,
50
51    #[error("Corrupt version data: version {version_id} has out-of-range bit_slot {slot} (expected 0..=63)")]
52    CorruptBitSlot { version_id: i64, slot: i64 },
53
54    #[error("Invalid entity type: {0}")]
55    InvalidEntityType(String),
56
57    #[error("Invalid input: {0}")]
58    InvalidInput(String),
59
60    #[error("Database is closed")]
61    DatabaseClosed,
62
63    #[error("Other error: {0}")]
64    Other(String),
65
66    #[error("background task failed: {0}")]
67    TaskPanicked(String),
68}