es_fluent_cli/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum CliError {
5    /// An error that occurs when parsing the `i18n.toml` configuration file.
6    #[error("Failed to parse i18n.toml configuration: {0}")]
7    ConfigParse(String),
8
9    /// An error that occurs when creating the i18n output directory.
10    #[error("Cannot create i18n output directory: {0}")]
11    CreateDir(#[from] std::io::Error),
12
13    /// An error that occurs when discovering the workspace metadata.
14    #[error("Failed to discover workspace metadata: {0}")]
15    WorkspaceDiscovery(String),
16
17    /// An error that occurs when watching files.
18    #[error("File watching error: {0}")]
19    Watch(#[from] notify::Error),
20
21    /// An error that occurs when parsing Fluent files.
22    #[error("Fluent parser error: {0}")]
23    FluentParser(String),
24
25    /// An error that occurs when generating Fluent files.
26    #[error("Fluent generation error: {0}")]
27    FluentGenerate(String),
28
29    /// An internal application error.
30    #[error("An internal application error occurred: {0}")]
31    Internal(String),
32}
33
34impl From<es_fluent_toml::I18nConfigError> for CliError {
35    fn from(err: es_fluent_toml::I18nConfigError) -> Self {
36        CliError::ConfigParse(err.to_string())
37    }
38}
39
40impl From<cargo_metadata::Error> for CliError {
41    fn from(err: cargo_metadata::Error) -> Self {
42        CliError::WorkspaceDiscovery(err.to_string())
43    }
44}
45
46impl From<es_fluent_sc_parser::error::FluentScParserError> for CliError {
47    fn from(err: es_fluent_sc_parser::error::FluentScParserError) -> Self {
48        CliError::FluentParser(err.to_string())
49    }
50}
51
52impl From<es_fluent_generate::error::FluentGenerateError> for CliError {
53    fn from(err: es_fluent_generate::error::FluentGenerateError) -> Self {
54        CliError::FluentGenerate(err.to_string())
55    }
56}