/home/noah/src/trueno/src/tuner/error.rs
Line | Count | Source |
1 | | //! Tuner Error Types |
2 | | //! |
3 | | //! Error types for the ML-based tuner. |
4 | | |
5 | | /// Tuner error type |
6 | | #[derive(Debug, Clone)] |
7 | | pub enum TunerError { |
8 | | /// Invalid feature value |
9 | | InvalidFeature(String), |
10 | | /// Insufficient training data |
11 | | InsufficientData(usize), |
12 | | /// Serialization error |
13 | | Serialization(String), |
14 | | /// Model not found |
15 | | ModelNotFound, |
16 | | /// Prediction failed |
17 | | PredictionFailed(String), |
18 | | /// Training failed (ml-tuner feature) |
19 | | TrainingFailed(String), |
20 | | /// I/O error (file operations) |
21 | | Io(String), |
22 | | /// Invalid format (APR magic/version mismatch) |
23 | | InvalidFormat(String), |
24 | | } |
25 | | |
26 | | impl std::fmt::Display for TunerError { |
27 | 0 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
28 | 0 | match self { |
29 | 0 | TunerError::InvalidFeature(msg) => write!(f, "Invalid feature: {}", msg), |
30 | 0 | TunerError::InsufficientData(n) => { |
31 | 0 | write!(f, "Insufficient training data: {} samples (need >= 10)", n) |
32 | | } |
33 | 0 | TunerError::Serialization(msg) => write!(f, "Serialization error: {}", msg), |
34 | 0 | TunerError::ModelNotFound => write!(f, "Tuner model not found"), |
35 | 0 | TunerError::PredictionFailed(msg) => write!(f, "Prediction failed: {}", msg), |
36 | 0 | TunerError::TrainingFailed(msg) => write!(f, "Training failed: {}", msg), |
37 | 0 | TunerError::Io(msg) => write!(f, "I/O error: {}", msg), |
38 | 0 | TunerError::InvalidFormat(msg) => write!(f, "Invalid format: {}", msg), |
39 | | } |
40 | 0 | } |
41 | | } |
42 | | |
43 | | impl std::error::Error for TunerError {} |