use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("invalid language code: {0} (must be 3 lowercase ASCII letters)")]
InvalidLangCode(String),
#[error("invalid feature bundle: {0}")]
InvalidFeatureBundle(String),
#[error("malformed entry at line {line}: {reason}")]
MalformedEntry { line: usize, reason: String },
#[error("language not found: {0}")]
LanguageNotFound(String),
#[error("download failed: {0}")]
DownloadFailed(String),
#[error("GitHub API rate limit exceeded, try again later")]
RateLimited,
#[error("database error: {0}")]
Database(#[from] rusqlite::Error),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
#[error("cache directory error: {path}: {reason}")]
CacheDir { path: PathBuf, reason: String },
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
}
pub type Result<T> = std::result::Result<T, Error>;