kwaai_distributed/
error.rs1use thiserror::Error;
4
5pub type DistributedResult<T> = Result<T, DistributedError>;
7
8#[derive(Error, Debug)]
10pub enum DistributedError {
11 #[error("Expert not found: {0}")]
13 ExpertNotFound(String),
14
15 #[error("Remote call failed: {0}")]
17 RemoteCallFailed(String),
18
19 #[error("Operation timed out after {0}ms")]
21 Timeout(u64),
22
23 #[error("No peers available for {0}")]
25 NoPeersAvailable(String),
26
27 #[error("Averaging failed: {0}")]
29 AveragingFailed(String),
30
31 #[error("Routing failed: {0}")]
33 RoutingFailed(String),
34
35 #[error("All retries exhausted: {0}")]
37 RetriesExhausted(String),
38
39 #[error("Network error: {0}")]
41 NetworkError(String),
42
43 #[error("Compression error: {0}")]
45 CompressionError(String),
46
47 #[error("Tensor error: {0}")]
49 TensorError(String),
50
51 #[error("Internal error: {0}")]
53 Internal(String),
54}
55
56impl From<kwaai_p2p::P2PError> for DistributedError {
57 fn from(err: kwaai_p2p::P2PError) -> Self {
58 DistributedError::NetworkError(err.to_string())
59 }
60}
61
62impl From<kwaai_compression::CompressionError> for DistributedError {
63 fn from(err: kwaai_compression::CompressionError) -> Self {
64 DistributedError::CompressionError(err.to_string())
65 }
66}
67
68impl From<candle_core::Error> for DistributedError {
69 fn from(err: candle_core::Error) -> Self {
70 DistributedError::TensorError(err.to_string())
71 }
72}