hive_gpu/
error.rs

1//! Error types for Hive GPU
2
3use thiserror::Error;
4
5/// Main error type for Hive GPU operations
6#[derive(Error, Debug)]
7pub enum HiveGpuError {
8    /// Invalid vector dimension
9    #[error("Invalid dimension: expected {expected}, got {got}")]
10    InvalidDimension { expected: usize, got: usize },
11
12    /// Dimension mismatch
13    #[error("Dimension mismatch: expected {expected}, got {actual}")]
14    DimensionMismatch { expected: usize, actual: usize },
15
16    /// VRAM limit exceeded
17    #[error("VRAM limit exceeded: requested {requested}, limit {limit}")]
18    VramLimitExceeded { requested: usize, limit: usize },
19
20    /// GPU operation failed
21    #[error("GPU operation failed: {0}")]
22    GpuOperationFailed(String),
23
24    /// No GPU device available
25    #[error("No GPU device available")]
26    NoDeviceAvailable,
27
28    /// Buffer allocation failed
29    #[error("Buffer allocation failed: {0}")]
30    BufferAllocationFailed(String),
31
32    /// Device initialization failed
33    #[error("Device initialization failed: {0}")]
34    DeviceInitializationFailed(String),
35
36    /// Shader compilation failed
37    #[error("Shader compilation failed: {0}")]
38    ShaderCompilationFailed(String),
39
40    /// Memory allocation failed
41    #[error("Memory allocation failed: {0}")]
42    MemoryAllocationFailed(String),
43
44    /// Search operation failed
45    #[error("Search operation failed: {0}")]
46    SearchFailed(String),
47
48    /// Vector not found
49    #[error("Vector not found: {0}")]
50    VectorNotFound(String),
51
52    /// Invalid configuration
53    #[error("Invalid configuration: {0}")]
54    InvalidConfiguration(String),
55
56    /// Internal error
57    #[error("Internal error: {0}")]
58    InternalError(String),
59
60    /// IO error
61    #[error("IO error: {0}")]
62    IoError(#[from] std::io::Error),
63
64    /// JSON error
65    #[error("JSON error: {0}")]
66    JsonError(#[from] serde_json::Error),
67
68    /// Other errors
69    #[error("{0}")]
70    Other(String),
71}
72
73/// Result type alias for Hive GPU operations
74pub type Result<T> = std::result::Result<T, HiveGpuError>;