ggen_config/
error.rs

1//! Error types for configuration parsing and validation
2
3use std::path::PathBuf;
4
5/// Result type alias for configuration operations
6pub type Result<T> = std::result::Result<T, ConfigError>;
7
8/// Errors that can occur during configuration operations
9#[derive(Debug, thiserror::Error)]
10pub enum ConfigError {
11    /// Configuration file not found
12    #[error("Configuration file not found: {0}")]
13    FileNotFound(PathBuf),
14
15    /// I/O error reading configuration
16    #[error("I/O error reading configuration: {0}")]
17    Io(#[from] std::io::Error),
18
19    /// TOML parsing error
20    #[error("TOML parsing error: {0}")]
21    TomlParse(#[from] toml::de::Error),
22
23    /// TOML serialization error
24    #[error("TOML serialization error: {0}")]
25    TomlSerialize(#[from] toml::ser::Error),
26
27    /// Configuration validation error
28    #[error("Configuration validation error: {0}")]
29    Validation(String),
30
31    /// Missing required field
32    #[error("Missing required field: {0}")]
33    MissingField(String),
34
35    /// Invalid value for field
36    #[error("Invalid value for field '{field}': {reason}")]
37    InvalidValue {
38        /// Field name
39        field: String,
40        /// Reason for invalidity
41        reason: String,
42    },
43
44    /// Environment variable expansion error
45    #[error("Environment variable error: {0}")]
46    EnvVar(String),
47
48    /// Workspace configuration error
49    #[error("Workspace configuration error: {0}")]
50    Workspace(String),
51}