polynode 0.13.11

Rust SDK for the PolyNode API — real-time Polymarket data
Documentation
//! Error types for the PolyNode SDK.

#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("HTTP request failed: {0}")]
    Http(#[from] reqwest::Error),

    #[error("WebSocket error: {0}")]
    WebSocket(#[from] tokio_tungstenite::tungstenite::Error),

    #[error("JSON error: {0}")]
    Json(#[from] serde_json::Error),

    #[error("API error ({status}): {message}")]
    Api { status: u16, message: String },

    #[error("Authentication failed: {0}")]
    Auth(String),

    #[error("Rate limited: {0}")]
    RateLimited(String),

    #[error("Not found: {0}")]
    NotFound(String),

    #[error("WebSocket disconnected")]
    Disconnected,

    #[error("Decompression failed: {0}")]
    Decompression(String),

    #[error("Connection closed by server")]
    ConnectionClosed,

    #[error("URL parse error: {0}")]
    Url(#[from] url::ParseError),

    #[cfg(feature = "cache")]
    #[error("SQLite error: {0}")]
    Sqlite(#[from] rusqlite::Error),

    #[cfg(feature = "cache")]
    #[error("Cache error: {0}")]
    Cache(String),

    #[cfg(feature = "cache")]
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    #[cfg(feature = "trading")]
    #[error("Trading error: {0}")]
    Trading(String),

    #[cfg(feature = "trading")]
    #[error("Signing error: {0}")]
    Signing(String),

    #[cfg(all(feature = "trading", not(feature = "cache")))]
    #[error("SQLite error: {0}")]
    Sqlite(#[from] rusqlite::Error),

    #[cfg(all(feature = "trading", not(feature = "cache")))]
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),
}

pub type Result<T> = std::result::Result<T, Error>;