kestrel_protocol_timer/
error.rs1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum TimerError {
6 InvalidSlotCount {
8 slot_count: usize,
9 reason: &'static str,
10 },
11
12 InvalidConfiguration {
14 field: String,
15 reason: String,
16 },
17
18 RegisterFailed,
20}
21
22impl fmt::Display for TimerError {
23 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 match self {
25 TimerError::InvalidSlotCount { slot_count, reason } => {
26 write!(f, "无效的槽位数量 {}: {}", slot_count, reason)
27 }
28 TimerError::InvalidConfiguration { field, reason } => {
29 write!(f, "配置验证失败 ({}): {}", field, reason)
30 }
31 TimerError::RegisterFailed => {
32 write!(f, "注册失败:内部通道已满或已关闭")
33 }
34 }
35 }
36}
37
38impl std::error::Error for TimerError {}
39