ricecoder_learning/
error.rs

1/// Learning system error types
2use thiserror::Error;
3
4/// Errors that can occur in the learning system
5#[derive(Debug, Error)]
6pub enum LearningError {
7    #[error("Decision capture failed: {0}")]
8    DecisionCaptureFailed(String),
9
10    #[error("Rule validation failed: {0}")]
11    RuleValidationFailed(String),
12
13    #[error("Rule storage failed: {0}")]
14    RuleStorageFailed(String),
15
16    #[error("Pattern extraction failed: {0}")]
17    PatternExtractionFailed(String),
18
19    #[error("Rule promotion failed: {0}")]
20    RulePromotionFailed(String),
21
22    #[error("Conflict resolution failed: {0}")]
23    ConflictResolutionFailed(String),
24
25    #[error("Configuration error: {0}")]
26    ConfigurationError(String),
27
28    #[error("Path resolution failed: {0}")]
29    PathResolutionFailed(String),
30
31    #[error("Serialization error: {0}")]
32    SerializationError(#[from] serde_json::Error),
33
34    #[error("Storage error: {0}")]
35    StorageError(String),
36
37    #[error("IO error: {0}")]
38    IoError(#[from] std::io::Error),
39
40    #[error("Invalid scope: {0}")]
41    InvalidScope(String),
42
43    #[error("Rule not found: {0}")]
44    RuleNotFound(String),
45
46    #[error("Pattern not found: {0}")]
47    PatternNotFound(String),
48
49    #[error("Decision not found: {0}")]
50    DecisionNotFound(String),
51
52    #[error("Rule application failed: {0}")]
53    RuleApplicationFailed(String),
54
55    #[error("Analytics error: {0}")]
56    AnalyticsError(String),
57}
58
59impl From<ricecoder_storage::error::StorageError> for LearningError {
60    fn from(err: ricecoder_storage::error::StorageError) -> Self {
61        LearningError::StorageError(err.to_string())
62    }
63}
64
65/// Result type for learning system operations
66pub type Result<T> = std::result::Result<T, LearningError>;