1use std::time::Duration;
4
5pub type GrammarResult<T> = Result<T, GrammarError>;
7
8#[derive(Debug, Clone, PartialEq)]
10pub enum GrammarError {
11 MissingWorkload,
13 InvalidDimensions(String),
15 InvalidScaleDomain { min: f64, max: f64 },
17 DeviceNotFound(u32),
19 Timeout(Duration),
21 UnsupportedStrategy(String),
23 ValidationError(String),
25 ExecutionError(String),
27}
28
29impl std::fmt::Display for GrammarError {
30 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31 match self {
32 GrammarError::MissingWorkload => write!(f, "Missing required workload specification"),
33 GrammarError::InvalidDimensions(msg) => write!(f, "Invalid dimensions: {}", msg),
34 GrammarError::InvalidScaleDomain { min, max } => {
35 write!(f, "Invalid scale domain: min {} >= max {}", min, max)
36 }
37 GrammarError::DeviceNotFound(id) => write!(f, "Device {} not found", id),
38 GrammarError::Timeout(d) => write!(f, "Execution timeout after {:?}", d),
39 GrammarError::UnsupportedStrategy(s) => write!(f, "Unsupported strategy: {}", s),
40 GrammarError::ValidationError(s) => write!(f, "Validation error: {}", s),
41 GrammarError::ExecutionError(s) => write!(f, "Execution error: {}", s),
42 }
43 }
44}
45
46impl std::error::Error for GrammarError {}