Skip to main content

cognee_llm/
error.rs

1//! Error types for LLM operations.
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum LlmError {
7    #[error("API request failed: {0}")]
8    ApiError(String),
9
10    #[error("Network error: {0}")]
11    NetworkError(String),
12
13    #[error("Serialization error: {0}")]
14    SerializationError(String),
15
16    #[error("Deserialization error: {0}")]
17    DeserializationError(String),
18
19    #[error("Invalid response format: {0}")]
20    InvalidResponse(String),
21
22    #[error("Rate limit exceeded: {0}")]
23    RateLimitExceeded(String),
24
25    #[error("Content policy violation: {0}")]
26    ContentPolicyViolation(String),
27
28    #[error("Model not found: {0}")]
29    ModelNotFound(String),
30
31    #[error("Authentication failed: {0}")]
32    AuthenticationError(String),
33
34    #[error("Timeout: {0}")]
35    Timeout(String),
36
37    #[error("Max retries exceeded: {0}")]
38    MaxRetriesExceeded(String),
39
40    #[error("Configuration error: {0}")]
41    ConfigError(String),
42
43    #[error("Feature not supported: {0}")]
44    FeatureNotSupported(String),
45
46    #[error("Local model error: {0}")]
47    LocalModelError(String),
48
49    #[error(
50        "Unsupported audio format: {0}. Supported formats: mp3, mp4, mpeg, mpga, m4a, wav, webm"
51    )]
52    InvalidAudioFormat(String),
53}
54
55/// Result type for LLM operations.
56pub type LlmResult<T> = Result<T, LlmError>;