haagenti_adaptive/
error.rs1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum AdaptiveError {
8 #[error("Invalid step {step}: must be in range [0, {total_steps})")]
10 InvalidStep { step: u32, total_steps: u32 },
11
12 #[error("Invalid transition from {from:?} to {to:?}: {reason}")]
14 InvalidTransition {
15 from: crate::Precision,
16 to: crate::Precision,
17 reason: String,
18 },
19
20 #[error("Precision {0:?} not supported by hardware")]
22 UnsupportedPrecision(crate::Precision),
23
24 #[error("Profile error: {0}")]
26 ProfileError(String),
27
28 #[error("Failed to generate schedule: {0}")]
30 ScheduleError(String),
31
32 #[error("VRAM constraint violated: required {required_mb}MB, available {available_mb}MB")]
34 VramConstraint { required_mb: u64, available_mb: u64 },
35
36 #[error("Quality below threshold: {actual:.3} < {threshold:.3}")]
38 QualityConstraint { actual: f32, threshold: f32 },
39}
40
41pub type Result<T> = std::result::Result<T, AdaptiveError>;
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_error_display() {
50 let err = AdaptiveError::InvalidStep {
51 step: 50,
52 total_steps: 30,
53 };
54 assert!(err.to_string().contains("50"));
55 assert!(err.to_string().contains("30"));
56 }
57}