ruvector_hyperbolic_hnsw/
error.rs

1//! Error types for hyperbolic HNSW operations
2
3use thiserror::Error;
4
5/// Errors that can occur during hyperbolic operations
6#[derive(Error, Debug, Clone)]
7pub enum HyperbolicError {
8    /// Vector is outside the Poincaré ball
9    #[error("Vector norm {norm} exceeds ball radius (1/sqrt(c) - eps) for curvature c={curvature}")]
10    OutsideBall { norm: f32, curvature: f32 },
11
12    /// Invalid curvature parameter
13    #[error("Invalid curvature: {0}. Must be positive.")]
14    InvalidCurvature(f32),
15
16    /// Dimension mismatch between vectors
17    #[error("Dimension mismatch: expected {expected}, got {got}")]
18    DimensionMismatch { expected: usize, got: usize },
19
20    /// Numerical instability detected
21    #[error("Numerical instability: {0}")]
22    NumericalInstability(String),
23
24    /// Shard not found
25    #[error("Shard not found: {0}")]
26    ShardNotFound(String),
27
28    /// Index out of bounds
29    #[error("Index {index} out of bounds for size {size}")]
30    IndexOutOfBounds { index: usize, size: usize },
31
32    /// Empty collection
33    #[error("Cannot perform operation on empty collection")]
34    EmptyCollection,
35
36    /// Search failed
37    #[error("Search failed: {0}")]
38    SearchFailed(String),
39}
40
41/// Result type for hyperbolic operations
42pub type HyperbolicResult<T> = Result<T, HyperbolicError>;