use thiserror::Error;

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

    #[error("unauthorized: missing x-api-key header")]
    Unauthorized,

    #[error("forbidden: invalid API key or inactive subscription")]
    Forbidden,

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

    #[error("holdings not supported for this account")]
    HoldingsNotSupported,

    #[error("server error: {0}")]
    ServerError(String),

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

    #[error("decode error: {0}")]
    Decode(String),

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

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