Skip to main content

irontide_tracker/
error.rs

1/// Convenience result type for tracker operations.
2pub type Result<T> = std::result::Result<T, Error>;
3
4/// Errors that can occur during tracker communication.
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7    /// Tracker returned an error message (BEP 31: may include retry guidance).
8    #[error("tracker returned error: {message}")]
9    TrackerError {
10        /// Human-readable error from the tracker.
11        message: String,
12        /// BEP 31: server-requested retry delay in seconds.
13        retry_in: Option<u32>,
14    },
15
16    /// Invalid or malformed tracker response.
17    #[error("invalid tracker response: {0}")]
18    InvalidResponse(String),
19
20    /// UDP tracker protocol error.
21    #[error("UDP protocol error: {0}")]
22    UdpProtocol(String),
23
24    /// Request timed out.
25    #[error("connection timed out")]
26    Timeout,
27
28    /// Bencode deserialization error.
29    #[error("bencode: {0}")]
30    Bencode(#[from] irontide_bencode::Error),
31
32    /// HTTP request error.
33    #[error("HTTP: {0}")]
34    Http(#[from] reqwest::Error),
35
36    /// Underlying I/O error.
37    #[error("I/O: {0}")]
38    Io(#[from] std::io::Error),
39
40    /// Invalid tracker URL.
41    #[error("invalid URL: {0}")]
42    InvalidUrl(String),
43
44    /// URL blocked by security policy (e.g., SSRF mitigation).
45    #[error("URL security policy violation: {0}")]
46    SecurityViolation(String),
47}