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("{0}")]
54 Other(String),
55}
56
57impl From<redb::Error> for VectorDbError {
58 fn from(err: redb::Error) -> Self {
59 VectorDbError::Database(err.to_string())
60 }
61}
62
63impl From<redb::DatabaseError> for VectorDbError {
64 fn from(err: redb::DatabaseError) -> Self {
65 VectorDbError::Database(err.to_string())
66 }
67}
68
69impl From<redb::StorageError> for VectorDbError {
70 fn from(err: redb::StorageError) -> Self {
71 VectorDbError::Storage(err.to_string())
72 }
73}
74
75impl From<redb::TransactionError> for VectorDbError {
76 fn from(err: redb::TransactionError) -> Self {
77 VectorDbError::Database(err.to_string())
78 }
79}
80
81impl From<redb::TableError> for VectorDbError {
82 fn from(err: redb::TableError) -> Self {
83 VectorDbError::Database(err.to_string())
84 }
85}
86
87impl From<redb::CommitError> for VectorDbError {
88 fn from(err: redb::CommitError) -> Self {
89 VectorDbError::Database(err.to_string())
90 }
91}