use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AssembleError {
EmptyInput,
HardBudgetViolation {
critical_tokens: u32,
budget: u32,
},
QueueFull {
max_in_flight: usize,
},
Timeout {
timeout_ms: u64,
},
WorkerFailed,
}
impl fmt::Display for AssembleError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::EmptyInput => write!(f, "no messages to assemble"),
Self::HardBudgetViolation {
critical_tokens,
budget,
} => write!(
f,
"hard budget violation: critical layers need {critical_tokens} tokens but budget is {budget}"
),
Self::QueueFull { max_in_flight } => {
write!(f, "assemble queue full (max_in_flight={max_in_flight})")
}
Self::Timeout { timeout_ms } => {
write!(f, "assemble timed out after {timeout_ms}ms")
}
Self::WorkerFailed => write!(f, "assemble worker failed"),
}
}
}
impl std::error::Error for AssembleError {}