1use std::fmt;
4
5pub type QdrantResult<T> = Result<T, QdrantError>;
7
8#[derive(Debug)]
10pub enum QdrantError {
11 Connection(String),
13 Grpc(String),
15 CollectionNotFound(String),
17 PointNotFound(String),
19 DimensionMismatch {
21 expected: usize,
23 got: usize,
25 },
26 Encode(String),
28 Decode(String),
30 Timeout,
32}
33
34impl fmt::Display for QdrantError {
35 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
36 match self {
37 QdrantError::Connection(msg) => write!(f, "Connection error: {}", msg),
38 QdrantError::Grpc(msg) => write!(f, "gRPC error: {}", msg),
39 QdrantError::CollectionNotFound(name) => write!(f, "Collection not found: {}", name),
40 QdrantError::PointNotFound(id) => write!(f, "Point not found: {}", id),
41 QdrantError::DimensionMismatch { expected, got } => {
42 write!(
43 f,
44 "Vector dimension mismatch: expected {}, got {}",
45 expected, got
46 )
47 }
48 QdrantError::Encode(msg) => write!(f, "Encode error: {}", msg),
49 QdrantError::Decode(msg) => write!(f, "Decode error: {}", msg),
50 QdrantError::Timeout => write!(f, "Operation timed out"),
51 }
52 }
53}
54
55impl std::error::Error for QdrantError {}