the-odds-api 0.1.1

A Rust SDK for The Odds API - sports odds and scores
Documentation
//! Error types for The Odds API SDK.

use thiserror::Error;

/// The main error type for The Odds API SDK.
#[derive(Error, Debug)]
pub enum Error {
    /// HTTP request failed.
    #[error("HTTP request failed: {0}")]
    Request(#[from] reqwest::Error),

    /// Failed to parse URL.
    #[error("Invalid URL: {0}")]
    Url(#[from] url::ParseError),

    /// API returned an error response.
    #[error("API error ({status}): {message}")]
    Api {
        status: u16,
        message: String,
    },

    /// Rate limit exceeded (HTTP 429).
    #[error("Rate limit exceeded. Requests remaining: {requests_remaining:?}")]
    RateLimited {
        requests_remaining: Option<u32>,
    },

    /// Invalid API key or unauthorized request (HTTP 401).
    #[error("Unauthorized: Invalid API key")]
    Unauthorized,

    /// JSON deserialization failed.
    #[error("Failed to deserialize response: {0}")]
    Deserialization(#[from] serde_json::Error),

    /// Missing required parameter.
    #[error("Missing required parameter: {0}")]
    MissingParameter(&'static str),

    /// Invalid parameter value.
    #[error("Invalid parameter value for {parameter}: {message}")]
    InvalidParameter {
        parameter: &'static str,
        message: String,
    },
}

/// A specialized Result type for The Odds API operations.
pub type Result<T> = std::result::Result<T, Error>;