//! Error types for provider-connections

use thiserror::Error;

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

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

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

    #[error("Token refresh failed: {status}")]
    TokenRefresh { status: u16 },

    #[error("Token expired and no refresh token available")]
    TokenExpired,

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

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