muster/domain/config/error.rs
1use std::path::PathBuf;
2
3use thiserror::Error;
4
5use crate::domain::{
6 process::ProcessKind,
7 value::{ProcessName, ProjectName},
8};
9
10/// Errors from workspace configuration and project registry operations.
11#[derive(Debug, Error)]
12pub enum ConfigError {
13 /// The configuration file could not be read from disk.
14 #[error("could not read config file {path}: {source}")]
15 Read {
16 /// Path that failed to load.
17 path: PathBuf,
18 /// Underlying I/O error.
19 source: std::io::Error,
20 },
21 /// The configuration file could not be written to disk.
22 #[error("could not write config file {path}: {source}")]
23 Write {
24 /// Path that failed to write.
25 path: PathBuf,
26 /// Underlying I/O error.
27 source: std::io::Error,
28 },
29 /// No writable config directory could be located on this platform.
30 #[error("no config directory is available")]
31 NoConfigDir,
32 /// A legacy registry entry has no stable location outside its original
33 /// launch directory.
34 #[error(
35 "registered project '{name}' uses unsupported relative config path {path:?}; edit or remove it in projects.yml"
36 )]
37 RelativeProjectConfig {
38 /// Registered project whose config path is ambiguous.
39 name: ProjectName,
40 /// Relative config path stored by an earlier version.
41 path: PathBuf,
42 },
43 /// The configuration was not valid YAML or violated the schema.
44 #[error("could not parse config: {0}")]
45 Parse(#[from] serde_yaml_ng::Error),
46 /// A non-command process configured command-only graceful shutdown.
47 #[error("{kind} process '{name}' configures stop, which is only valid for commands")]
48 InvalidStopPolicy {
49 /// Section containing the invalid process.
50 kind: ProcessKind,
51 /// Name of the invalid process.
52 name: ProcessName,
53 },
54}