ruvector_router_core/
error.rs1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, VectorDbError>;
7
8#[derive(Error, Debug)]
10pub enum VectorDbError {
11 #[error("IO error: {0}")]
13 Io(#[from] std::io::Error),
14
15 #[error("Storage error: {0}")]
17 Storage(String),
18
19 #[error("Index error: {0}")]
21 Index(String),
22
23 #[error("Quantization error: {0}")]
25 Quantization(String),
26
27 #[error("Invalid dimensions: expected {expected}, got {actual}")]
29 InvalidDimensions {
30 expected: usize,
32 actual: usize,
34 },
35
36 #[error("Vector not found: {0}")]
38 NotFound(String),
39
40 #[error("Invalid configuration: {0}")]
42 InvalidConfig(String),
43
44 #[error("Serialization error: {0}")]
46 Serialization(String),
47
48 #[error("Database error: {0}")]
50 Database(String),
51
52 #[error("Invalid path: {0}")]
54 InvalidPath(String),
55
56 #[error("{0}")]
58 Other(String),
59}
60
61impl From<redb::Error> for VectorDbError {
62 fn from(err: redb::Error) -> Self {
63 VectorDbError::Database(err.to_string())
64 }
65}
66
67impl From<redb::DatabaseError> for VectorDbError {
68 fn from(err: redb::DatabaseError) -> Self {
69 VectorDbError::Database(err.to_string())
70 }
71}
72
73impl From<redb::StorageError> for VectorDbError {
74 fn from(err: redb::StorageError) -> Self {
75 VectorDbError::Storage(err.to_string())
76 }
77}
78
79impl From<redb::TransactionError> for VectorDbError {
80 fn from(err: redb::TransactionError) -> Self {
81 VectorDbError::Database(err.to_string())
82 }
83}
84
85impl From<redb::TableError> for VectorDbError {
86 fn from(err: redb::TableError) -> Self {
87 VectorDbError::Database(err.to_string())
88 }
89}
90
91impl From<redb::CommitError> for VectorDbError {
92 fn from(err: redb::CommitError) -> Self {
93 VectorDbError::Database(err.to_string())
94 }
95}