1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum CliError {
5 #[error("Failed to parse i18n.toml configuration: {0}")]
7 ConfigParse(String),
8
9 #[error("Cannot create i18n output directory: {0}")]
11 CreateDir(#[from] std::io::Error),
12
13 #[error("Failed to discover workspace metadata: {0}")]
15 WorkspaceDiscovery(String),
16
17 #[error("File watching error: {0}")]
19 Watch(#[from] notify::Error),
20
21 #[error("Fluent parser error: {0}")]
23 FluentParser(String),
24
25 #[error("Fluent generation error: {0}")]
27 FluentGenerate(String),
28
29 #[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}