1use std::fmt;
4
5#[derive(Debug)]
7pub enum VectorError {
8 CollectionNotFound(String),
10 DimensionMismatch { expected: usize, actual: usize },
12 Unsupported(String),
14 Query(String),
16 Connection(String),
18 InvalidConfig(String),
20 InvalidIdentifier(String),
22 TopKExceeded { requested: usize, max: usize },
24}
25
26impl fmt::Display for VectorError {
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 match self {
29 VectorError::CollectionNotFound(name) => {
30 write!(f, "collection not found: {}", name)
31 }
32 VectorError::DimensionMismatch { expected, actual } => {
33 write!(
34 f,
35 "dimension mismatch: expected {}, got {}",
36 expected, actual
37 )
38 }
39 VectorError::Unsupported(msg) => {
40 write!(f, "unsupported operation: {}", msg)
41 }
42 VectorError::Query(msg) => write!(f, "query error: {}", msg),
43 VectorError::Connection(msg) => write!(f, "connection error: {}", msg),
44 VectorError::InvalidConfig(msg) => write!(f, "invalid config: {}", msg),
45 VectorError::InvalidIdentifier(msg) => write!(f, "invalid identifier: {}", msg),
46 VectorError::TopKExceeded { requested, max } => {
47 write!(f, "top_k {} exceeds maximum allowed {}", requested, max)
48 }
49 }
50 }
51}
52
53impl std::error::Error for VectorError {}