dht_crawler/error.rs
1use thiserror::Error;
2
3#[derive(Error, Debug)]
4/// Error returned during DHT initialization or execution.
5pub enum DHTError {
6 /// Socket or other network I/O failed.
7 #[error("网络错误: {0}")]
8 Network(#[from] std::io::Error),
9
10 /// A shared lock was poisoned.
11 #[error("锁中毒: {0}")]
12 LockPoisoned(String),
13
14 /// Server initialization failed, for example because a socket could not bind.
15 #[error("初始化错误: {0}")]
16 Init(String),
17
18 /// An internal invariant or worker operation failed.
19 #[error("内部错误: {0}")]
20 Internal(String),
21
22 /// Another error represented by a human-readable message.
23 #[error("{0}")]
24 Other(String),
25}
26
27/// Result type used by the crate's public APIs.
28pub type Result<T> = std::result::Result<T, DHTError>;