aether_core/
error.rs

1//! Error types for Aether Core.
2
3use thiserror::Error;
4
5/// Result type alias for Aether operations.
6pub type Result<T> = std::result::Result<T, AetherError>;
7
8/// Main error type for the Aether framework.
9#[derive(Debug, Error)]
10pub enum AetherError {
11    /// Template parsing failed.
12    #[error("Template parse error: {0}")]
13    TemplateParse(String),
14
15    /// Slot not found in template.
16    #[error("Slot '{0}' not found in template")]
17    SlotNotFound(String),
18
19    /// AI provider returned an error.
20    #[error("AI provider error: {0}")]
21    ProviderError(String),
22
23    /// Validation failed during self-healing.
24    #[error("Validation failed for slot '{slot}': {error}")]
25    ValidationFailed { slot: String, error: String },
26
27    /// Maximum retries exceeded during self-healing.
28    #[error("Maximum retries ({retries}) exceeded for slot '{slot}'. Last error: {last_error}")]
29    MaxRetriesExceeded { slot: String, retries: u32, last_error: String },
30
31    /// Network request failed.
32    #[error("Network error: {0}")]
33    NetworkError(String),
34
35    /// Code injection failed.
36    #[error("Injection error: {0}")]
37    InjectionError(String),
38
39    /// Invalid configuration.
40    #[error("Configuration error: {0}")]
41    ConfigError(String),
42
43    /// Template rendering failed.
44    #[error("Render error: {0}")]
45    RenderError(String),
46
47    /// IO operation failed.
48    #[error("IO error: {0}")]
49    IoError(#[from] std::io::Error),
50
51    /// JSON serialization/deserialization failed.
52    #[error("JSON error: {0}")]
53    JsonError(#[from] serde_json::Error),
54
55    /// Error during context serialization (e.g., for TOON)
56    #[error("Context serialization failed: {0}")]
57    ContextSerializationError(String),
58
59    /// Timeout occurred.
60    #[error("Operation timed out after {0} seconds")]
61    Timeout(u64),
62}