rustywallet_mempool/
error.rs

1//! Error types for Mempool.space API client.
2
3use thiserror::Error;
4
5/// Errors that can occur during Mempool API operations.
6#[derive(Debug, Error)]
7pub enum MempoolError {
8    /// HTTP request failed
9    #[error("HTTP error: {0}")]
10    HttpError(#[from] reqwest::Error),
11
12    /// API returned an error response
13    #[error("API error ({status}): {message}")]
14    ApiError {
15        /// HTTP status code
16        status: u16,
17        /// Error message from API
18        message: String,
19    },
20
21    /// Failed to parse API response
22    #[error("Parse error: {0}")]
23    ParseError(String),
24
25    /// Request timeout
26    #[error("Request timeout")]
27    Timeout,
28
29    /// Rate limited by API
30    #[error("Rate limited - too many requests")]
31    RateLimited,
32
33    /// Invalid address format
34    #[error("Invalid address: {0}")]
35    InvalidAddress(String),
36
37    /// Invalid transaction ID
38    #[error("Invalid txid: {0}")]
39    InvalidTxid(String),
40
41    /// Transaction not found
42    #[error("Transaction not found: {0}")]
43    TxNotFound(String),
44
45    /// Address not found
46    #[error("Address not found: {0}")]
47    AddressNotFound(String),
48
49    /// WebSocket error
50    #[error("WebSocket error: {0}")]
51    WebSocketError(String),
52
53    /// WebSocket connection closed
54    #[error("WebSocket connection closed")]
55    WebSocketClosed,
56
57    /// Lightning API error
58    #[error("Lightning API error: {0}")]
59    LightningError(String),
60
61    /// Mining API error
62    #[error("Mining API error: {0}")]
63    MiningError(String),
64}
65
66/// Result type alias for Mempool operations.
67pub type Result<T> = std::result::Result<T, MempoolError>;