Skip to main content

ferro_lang/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur during translation loading and lookup.
4#[derive(Debug, Error)]
5pub enum LangError {
6    /// File reading failure.
7    #[error("failed to read translation file: {0}")]
8    IoError(#[from] std::io::Error),
9
10    /// JSON parse failure.
11    #[error("failed to parse translation JSON: {0}")]
12    JsonError(#[from] serde_json::Error),
13
14    /// No translation files found in the given path.
15    #[error("no translations loaded from the given path")]
16    NoTranslationsLoaded,
17
18    /// Requested locale is not loaded.
19    #[error("invalid locale: {locale}")]
20    InvalidLocale {
21        /// The locale identifier that was not found.
22        locale: String,
23    },
24
25    /// Configuration-level error (e.g. lang path does not exist).
26    #[error("lang config error: {message}")]
27    ConfigError {
28        /// Description of the configuration problem.
29        message: String,
30    },
31}