qail_qdrant/
error.rs

1//! Error types for Qdrant driver.
2
3use std::fmt;
4
5/// Result type for Qdrant operations.
6pub type QdrantResult<T> = Result<T, QdrantError>;
7
8/// Errors that can occur during Qdrant operations.
9#[derive(Debug)]
10pub enum QdrantError {
11    /// Connection failed.
12    Connection(String),
13    /// gRPC error.
14    Grpc(String),
15    /// Collection not found.
16    CollectionNotFound(String),
17    /// Point not found.
18    PointNotFound(String),
19    /// Invalid vector dimension.
20    DimensionMismatch { expected: usize, got: usize },
21    /// Encoding error.
22    Encode(String),
23    /// Decode error.
24    Decode(String),
25    /// Timeout.
26    Timeout,
27}
28
29impl fmt::Display for QdrantError {
30    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31        match self {
32            QdrantError::Connection(msg) => write!(f, "Connection error: {}", msg),
33            QdrantError::Grpc(msg) => write!(f, "gRPC error: {}", msg),
34            QdrantError::CollectionNotFound(name) => write!(f, "Collection not found: {}", name),
35            QdrantError::PointNotFound(id) => write!(f, "Point not found: {}", id),
36            QdrantError::DimensionMismatch { expected, got } => {
37                write!(f, "Vector dimension mismatch: expected {}, got {}", expected, got)
38            }
39            QdrantError::Encode(msg) => write!(f, "Encode error: {}", msg),
40            QdrantError::Decode(msg) => write!(f, "Decode error: {}", msg),
41            QdrantError::Timeout => write!(f, "Operation timed out"),
42        }
43    }
44}
45
46impl std::error::Error for QdrantError {}