unimorph_core/
error.rs

1//! Error types for unimorph-core.
2
3use std::path::PathBuf;
4
5/// Errors that can occur when working with UniMorph data.
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8    /// Invalid ISO 639-3 language code.
9    #[error("invalid language code: {0} (must be 3 lowercase ASCII letters)")]
10    InvalidLangCode(String),
11
12    /// Invalid feature bundle string.
13    #[error("invalid feature bundle: {0}")]
14    InvalidFeatureBundle(String),
15
16    /// Malformed entry in TSV data.
17    #[error("malformed entry at line {line}: {reason}")]
18    MalformedEntry { line: usize, reason: String },
19
20    /// Language not found in the store.
21    #[error("language not found: {0}")]
22    LanguageNotFound(String),
23
24    /// Dataset download failed.
25    #[error("download failed: {0}")]
26    DownloadFailed(String),
27
28    /// GitHub API rate limit exceeded.
29    #[error("GitHub API rate limit exceeded, try again later")]
30    RateLimited,
31
32    /// Decompression failed.
33    #[error("decompression failed: {0}")]
34    DecompressionFailed(String),
35
36    /// Database error.
37    #[error("database error: {0}")]
38    Database(#[from] rusqlite::Error),
39
40    /// I/O error.
41    #[error("I/O error: {0}")]
42    Io(#[from] std::io::Error),
43
44    /// HTTP request error.
45    #[error("HTTP error: {0}")]
46    Http(#[from] reqwest::Error),
47
48    /// Cache directory not found or not writable.
49    #[error("cache directory error: {path}: {reason}")]
50    CacheDir { path: PathBuf, reason: String },
51
52    /// JSON serialization/deserialization error.
53    #[error("JSON error: {0}")]
54    Json(#[from] serde_json::Error),
55}
56
57/// Result type alias for this crate.
58pub type Result<T> = std::result::Result<T, Error>;