/// Privy client errors.
#[derive(Debug, thiserror::Error)]
pub enum PrivyError {
    /// Invalid configuration (bad key format, missing prefix, etc.).
    #[error("Privy config error: {0}")]
    Config(String),
    /// HTTP request failed.
    #[error("Privy HTTP error: {0}")]
    Http(#[from] reqwest::Error),
    /// Privy API returned an error response.
    #[error("Privy API error ({status}): {body}")]
    Api { status: u16, body: String },
    /// JSON serialization/deserialization failed.
    #[error("Privy serialization error: {0}")]
    Serialization(String),
}

impl From<serde_json::Error> for PrivyError {
    fn from(e: serde_json::Error) -> Self {
        Self::Serialization(e.to_string())
    }
}

pub type PrivyResult<T> = Result<T, PrivyError>;
