use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TimerError {
InvalidSlotCount {
slot_count: usize,
reason: &'static str,
},
InvalidConfiguration {
field: String,
reason: String,
},
RegisterFailed,
}
impl fmt::Display for TimerError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TimerError::InvalidSlotCount { slot_count, reason } => {
write!(f, "无效的槽位数量 {}: {}", slot_count, reason)
}
TimerError::InvalidConfiguration { field, reason } => {
write!(f, "配置验证失败 ({}): {}", field, reason)
}
TimerError::RegisterFailed => {
write!(f, "注册失败:内部通道已满或已关闭")
}
}
}
}
impl std::error::Error for TimerError {}