Skip to content

Commit

Permalink
Improve configuration error messages
Browse files Browse the repository at this point in the history
Rel #24
  • Loading branch information
breard-r committed Aug 25, 2020
1 parent 566d09a commit 87f97ec
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions acmed/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,13 @@ fn get_cnf_path(from: &PathBuf, file: &str) -> Result<Vec<PathBuf>, Error> {

fn read_cnf(path: &PathBuf) -> Result<Config, Error> {
info!("Loading configuration file: {}", path.display());
let mut file = File::open(path)?;
let mut file =
File::open(path).map_err(|e| Error::from(e).prefix(&path.display().to_string()))?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
let mut config: Config = toml::from_str(&contents)?;
file.read_to_string(&mut contents)
.map_err(|e| Error::from(e).prefix(&path.display().to_string()))?;
let mut config: Config = toml::from_str(&contents)
.map_err(|e| Error::from(e).prefix(&path.display().to_string()))?;
for cnf_name in config.include.iter() {
for cnf_path in get_cnf_path(path, cnf_name)? {
let mut add_cnf = read_cnf(&cnf_path)?;
Expand Down

0 comments on commit 87f97ec

Please sign in to comment.