Skip to main content

goldrush_sdk/
error.rs

1use thiserror::Error;
2
3/// Error types that can occur when using the GoldRush SDK.
4#[derive(Debug, Error)]
5pub enum Error {
6    /// The API key was not provided or is empty.
7    #[error("missing API key")]
8    MissingApiKey,
9
10    /// HTTP client errors (network issues, timeouts, etc.).
11    #[error("HTTP error: {0}")]
12    Http(#[from] reqwest::Error),
13
14    /// JSON serialization/deserialization errors.
15    #[error("serialization error: {0}")]
16    Serialization(#[from] serde_json::Error),
17
18    /// API errors returned by the GoldRush service.
19    #[error("API error {status}: {message}")]
20    Api {
21        /// HTTP status code
22        status: u16,
23        /// Error message from the API
24        message: String,
25        /// Optional error code from the API
26        code: Option<u32>,
27    },
28
29    /// Invalid configuration provided.
30    #[error("configuration error: {0}")]
31    Config(String),
32}
33
34/// Result type alias for GoldRush SDK operations.
35pub type Result<T> = std::result::Result<T, Error>;