use thiserror::Error;

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

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

    #[error("authentication required")]
    AuthRequired,

    #[error("invalid credentials")]
    InvalidCredentials,

    #[error("rate limited")]
    RateLimited(Option<u64>),

    #[error("user not found / {0}")]
    UserNotFound(String),

    #[error("media not found / {0}")]
    MediaNotFound(String),

    #[error("session expired")]
    SessionExpired,

    #[error("blocked by instagram")]
    Blocked,

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

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