use std::path::PathBuf;
use thiserror::Error;
use crate::domain::{
process::ProcessKind,
value::{ProcessName, ProjectName},
};
#[derive(Debug, Error)]
pub enum ConfigError {
#[error("could not read config file {path}: {source}")]
Read {
path: PathBuf,
source: std::io::Error,
},
#[error("could not write config file {path}: {source}")]
Write {
path: PathBuf,
source: std::io::Error,
},
#[error("no config directory is available")]
NoConfigDir,
#[error(
"registered project '{name}' uses unsupported relative config path {path:?}; edit or remove it in projects.yml"
)]
RelativeProjectConfig {
name: ProjectName,
path: PathBuf,
},
#[error("could not parse config: {0}")]
Parse(#[from] serde_yaml_ng::Error),
#[error("{kind} process '{name}' configures stop, which is only valid for commands")]
InvalidStopPolicy {
kind: ProcessKind,
name: ProcessName,
},
}