Skip to main content

mentedb_extraction/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur during memory extraction.
4#[derive(Debug, Error)]
5pub enum ExtractionError {
6    /// The LLM provider returned an error or was unreachable.
7    #[error("provider error: {0}")]
8    ProviderError(String),
9
10    /// The LLM response could not be parsed as valid extraction output.
11    #[error("parse error: {0}")]
12    ParseError(String),
13
14    /// The extraction configuration is invalid.
15    #[error("config error: {0}")]
16    ConfigError(String),
17
18    /// An HTTP request failed.
19    #[error("http error: {0}")]
20    HttpError(String),
21
22    /// An embedding operation failed.
23    #[error("embedding error: {0}")]
24    EmbeddingError(String),
25
26    /// Rate limit exceeded after all retry attempts.
27    #[error("rate limit exceeded after {attempts} attempts")]
28    RateLimitExceeded { attempts: usize },
29}
30
31impl From<reqwest::Error> for ExtractionError {
32    fn from(e: reqwest::Error) -> Self {
33        ExtractionError::HttpError(e.to_string())
34    }
35}
36
37impl From<serde_json::Error> for ExtractionError {
38    fn from(e: serde_json::Error) -> Self {
39        ExtractionError::ParseError(e.to_string())
40    }
41}