better error message about missing config

This commit is contained in:
Nick Pegg 2025-05-07 20:57:14 -07:00
parent 396b434b39
commit 0d9d632195

View file

@ -17,8 +17,12 @@ pub struct Config {
impl Config {
pub fn from_album(path: PathBuf) -> anyhow::Result<Config> {
let config_path = path.join("photojawn.conf.yml");
let content = fs::read(&config_path)
.with_context(|| format!("Failed to read config from {}", config_path.display()))?;
let content = fs::read(&config_path).with_context(|| {
format!(
"Failed to read config from {}. Is this an album directory?",
config_path.display(),
)
})?;
let cfg = serde_yml::from_slice(&content)
.with_context(|| format!("Failed to parse config from {}", config_path.display()))?;
Ok(cfg)