diff --git a/site-builder/src/config.rs b/site-builder/src/config.rs index 706f3416..cd647561 100644 --- a/site-builder/src/config.rs +++ b/site-builder/src/config.rs @@ -73,8 +73,16 @@ impl Config { path: impl AsRef, context: Option<&str>, ) -> Result<(Self, Option)> { - let multi_config = - serde_yaml::from_str::(&std::fs::read_to_string(path.as_ref())?)?; + let config_content = std::fs::read_to_string(path.as_ref()) + .map_err(|e| anyhow!( + "could not read site builder config file '{}': {e}", + path.as_ref().display() + ))?; + let multi_config = serde_yaml::from_str::(&config_content) + .map_err(|e| anyhow!( + "could not parse site builder config file '{}': {e}", + path.as_ref().display() + ))?; match multi_config { MultiConfig::SingletonConfig(config) => { @@ -97,7 +105,11 @@ impl Config { Ok(( contexts .remove(context) - .ok_or_else(|| anyhow!("could not find the context: {}", context))?, + .ok_or_else(|| anyhow!( + "could not find the context '{}' in site builder config file '{}'", + context, + path.as_ref().display() + ))?, Some(context.to_owned()), )) }