hypembed/error/
mod.rs

1/// Error types for the HypEmbed library.
2///
3/// All public functions return `Result<T, HypEmbedError>`.
4/// Errors carry context to help diagnose issues.
5
6use thiserror::Error;
7
8/// The main error type for HypEmbed.
9#[derive(Error, Debug)]
10pub enum HypEmbedError {
11    /// Tensor operation error (shape mismatch, invalid index, etc.)
12    #[error("Tensor error: {0}")]
13    Tensor(String),
14
15    /// Tokenizer error (vocab loading, encoding, etc.)
16    #[error("Tokenizer error: {0}")]
17    Tokenizer(String),
18
19    /// Model error (weight loading, config parsing, forward pass)
20    #[error("Model error: {0}")]
21    Model(String),
22
23    /// IO error (file not found, read failure)
24    #[error("IO error: {source}")]
25    Io {
26        #[from]
27        source: std::io::Error,
28    },
29
30    /// JSON parsing error
31    #[error("JSON error: {source}")]
32    Json {
33        #[from]
34        source: serde_json::Error,
35    },
36}
37
38/// Convenience type alias.
39pub type Result<T> = std::result::Result<T, HypEmbedError>;