Skip to main content

ares_vector/
error.rs

1//! Error types for ares-vector.
2
3use thiserror::Error;
4
5/// Result type for ares-vector operations.
6pub type Result<T> = std::result::Result<T, Error>;
7
8/// Errors that can occur in ares-vector operations.
9#[derive(Error, Debug)]
10pub enum Error {
11    /// Collection already exists.
12    #[error("Collection '{0}' already exists")]
13    CollectionExists(String),
14
15    /// Collection not found.
16    #[error("Collection '{0}' not found")]
17    CollectionNotFound(String),
18
19    /// Vector not found.
20    #[error("Vector '{0}' not found")]
21    VectorNotFound(String),
22
23    /// Dimension mismatch between vector and collection.
24    #[error("Dimension mismatch: expected {expected}, got {actual}")]
25    DimensionMismatch {
26        /// Expected dimensions.
27        expected: usize,
28        /// Actual dimensions provided.
29        actual: usize,
30    },
31
32    /// Invalid vector (e.g., empty, contains NaN).
33    #[error("Invalid vector: {0}")]
34    InvalidVector(String),
35
36    /// Index error during HNSW operations.
37    #[error("Index error: {0}")]
38    Index(String),
39
40    /// Persistence error (I/O, serialization, etc.).
41    #[error("Persistence error: {0}")]
42    Persistence(String),
43
44    /// Configuration error.
45    #[error("Configuration error: {0}")]
46    Configuration(String),
47
48    /// I/O error.
49    #[error("I/O error: {0}")]
50    Io(#[from] std::io::Error),
51
52    /// Internal error.
53    #[error("Internal error: {0}")]
54    Internal(String),
55}