1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum TimerError {
8 InvalidSlotCount {
12 slot_count: usize,
13 reason: &'static str,
14 },
15
16 InvalidConfiguration {
20 field: String,
21 reason: String,
22 },
23
24 RegisterFailed,
28}
29
30impl fmt::Display for TimerError {
31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 match self {
33 TimerError::InvalidSlotCount { slot_count, reason } => {
34 write!(f, "Invalid slot count {}: {} (无效的槽位数 {}: {})", slot_count, reason, slot_count, reason)
35 }
36 TimerError::InvalidConfiguration { field, reason } => {
37 write!(f, "Configuration validation failed ({}): {} (配置验证失败 ({}): {})", field, reason, field, reason)
38 }
39 TimerError::RegisterFailed => {
40 write!(f, "Registration failed: internal channel is full or closed (注册失败: 内部通道已满或已关闭)")
41 }
42 }
43 }
44}
45
46impl std::error::Error for TimerError {}
47