Skip to main content

cognee_embedding/
error.rs

1use thiserror::Error;
2
3/// Error type for embedding engine operations.
4#[derive(Error, Debug)]
5pub enum EmbeddingError {
6    /// Failed to load the embedding model.
7    #[error("Model load error: {0}")]
8    ModelLoadError(String),
9
10    /// Tokenizer-related failure.
11    #[error("Tokenizer error: {0}")]
12    TokenizerError(String),
13
14    /// Inference execution failed.
15    #[error("Inference error: {0}")]
16    InferenceError(String),
17
18    /// Invalid or missing configuration.
19    #[error("Configuration error: {0}")]
20    ConfigError(String),
21
22    /// An I/O error occurred.
23    #[error("IO error: {0}")]
24    IoError(#[from] std::io::Error),
25
26    /// The requested provider is not yet implemented.
27    #[error("Provider not implemented: {0}")]
28    NotImplemented(String),
29
30    /// HTTP-level error (network failure, rate-limit 429, server 5xx).
31    /// These are considered transient and will be retried by the engine.
32    #[error("HTTP error: {0}")]
33    HttpError(String),
34
35    /// API-level error (4xx other than 429, unexpected response shape).
36    /// These are not retried.
37    #[error("API error: {0}")]
38    ApiError(String),
39}
40
41/// Convenience `Result` alias for embedding engine operations.
42pub type EmbeddingResult<T> = Result<T, EmbeddingError>;