Skip to main content

muster/domain/config/
error.rs

1use std::path::PathBuf;
2
3use thiserror::Error;
4
5use crate::domain::{process::ProcessKind, value::ProcessName};
6
7/// Errors from loading or parsing the workspace configuration.
8#[derive(Debug, Error)]
9pub enum ConfigError {
10    /// The configuration file could not be read from disk.
11    #[error("could not read config file {path}: {source}")]
12    Read {
13        /// Path that failed to load.
14        path: PathBuf,
15        /// Underlying I/O error.
16        source: std::io::Error,
17    },
18    /// The configuration file could not be written to disk.
19    #[error("could not write config file {path}: {source}")]
20    Write {
21        /// Path that failed to write.
22        path: PathBuf,
23        /// Underlying I/O error.
24        source: std::io::Error,
25    },
26    /// No writable config directory could be located on this platform.
27    #[error("no config directory is available")]
28    NoConfigDir,
29    /// The configuration was not valid YAML or violated the schema.
30    #[error("could not parse config: {0}")]
31    Parse(#[from] serde_yaml_ng::Error),
32    /// A non-command process configured command-only graceful shutdown.
33    #[error("{kind} process '{name}' configures stop, which is only valid for commands")]
34    InvalidStopPolicy {
35        /// Section containing the invalid process.
36        kind: ProcessKind,
37        /// Name of the invalid process.
38        name: ProcessName,
39    },
40}