Skip to main content

cp_tor/
error.rs

1//! Error types for the Canon Tor protocol layer.
2
3use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, TorError>;
6
7#[derive(Error, Debug)]
8pub enum TorError {
9    #[error("IO error: {0}")]
10    Io(#[from] std::io::Error),
11
12    #[error("Serialization error: {0}")]
13    Serialization(String),
14
15    #[error("Message too large: {size} bytes (max {max})")]
16    MessageTooLarge { size: usize, max: usize },
17
18    #[error("Signature verification failed: {0}")]
19    Verification(String),
20
21    #[error("Rate limited")]
22    RateLimited,
23
24    #[error("Search timeout")]
25    Timeout,
26
27    #[error("Model mismatch: peer uses a different embedding model")]
28    ModelMismatch,
29
30    #[error("Peer overloaded")]
31    PeerOverloaded,
32
33    #[error("Invalid request: {0}")]
34    InvalidRequest(String),
35
36    #[error("No peers available")]
37    NoPeers,
38
39    #[error("Keepalive probe received")]
40    Keepalive,
41
42    #[error("Peer registration expired")]
43    PeerExpired,
44
45    #[error("Connection failed: {0}")]
46    Connection(String),
47}