//! Error types for the Synor Compute SDK.

use thiserror::Error;

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

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

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

    /// Invalid argument.
    #[error("Invalid argument: {0}")]
    InvalidArgument(String),

    /// Client has been closed.
    #[error("Client has been closed")]
    ClientClosed,
}

/// Result type alias for SDK operations.
pub type Result<T> = std::result::Result<T, Error>;
