use std::fmt;
pub type QdrantResult<T> = Result<T, QdrantError>;
#[derive(Debug)]
pub enum QdrantError {
Connection(String),
Grpc(String),
CollectionNotFound(String),
PointNotFound(String),
DimensionMismatch { expected: usize, got: usize },
Encode(String),
Decode(String),
Timeout,
}
impl fmt::Display for QdrantError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
QdrantError::Connection(msg) => write!(f, "Connection error: {}", msg),
QdrantError::Grpc(msg) => write!(f, "gRPC error: {}", msg),
QdrantError::CollectionNotFound(name) => write!(f, "Collection not found: {}", name),
QdrantError::PointNotFound(id) => write!(f, "Point not found: {}", id),
QdrantError::DimensionMismatch { expected, got } => {
write!(f, "Vector dimension mismatch: expected {}, got {}", expected, got)
}
QdrantError::Encode(msg) => write!(f, "Encode error: {}", msg),
QdrantError::Decode(msg) => write!(f, "Decode error: {}", msg),
QdrantError::Timeout => write!(f, "Operation timed out"),
}
}
}
impl std::error::Error for QdrantError {}