Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,18 +544,22 @@ impl Config {
}
(true, false) => (toml_path, ConfigFormat::Toml),
(false, true) => (json_path, ConfigFormat::Json),
(false, false) => bail!("no config file found (expected config.toml or config.json)"),
(false, false) => bail!(
"no config file found in '{}' (expected config.toml or config.json)",
work_dir.display()
),
};

log::debug!("Parsing config from file '{}'...", path.display());
let content = fs::read_to_string(&path).context("failed to read config file")?;
let content = fs::read_to_string(&path)
.with_context(|| format!("failed to read config file '{}'", path.display()))?;
let mut config: Config = match format {
ConfigFormat::Toml => {
toml::from_str(&content).context("failed to parse config TOML file")?
}
ConfigFormat::Json => {
serde_json::from_str(&content).context("failed to parse config JSON file")?
}
ConfigFormat::Toml => toml::from_str(&content).with_context(|| {
format!("failed to parse config TOML file '{}'", path.display())
})?,
ConfigFormat::Json => serde_json::from_str(&content).with_context(|| {
format!("failed to parse config JSON file '{}'", path.display())
})?,
};
config.work_dir = work_dir.to_path_buf();

Expand Down
Loading