diff --git a/meilisearch-http/src/main.rs b/meilisearch-http/src/main.rs index 01cf39a2f..b6f92ae28 100644 --- a/meilisearch-http/src/main.rs +++ b/meilisearch-http/src/main.rs @@ -119,7 +119,7 @@ pub fn print_launch_resume(opt: &Opt, user: &str, config_read_from: Option { // If the file is successfully read, we deserialize it with `toml`. - match toml::from_slice::(&config) { - Ok(opt_from_config) => { - // We inject the values from the toml in the corresponding env vars if needs be. Doing so, we respect the priority toml < env vars < cli args. - opt_from_config.export_to_env(); - // Once injected we parse the cli args once again to take the new env vars into scope. - opts = Opt::parse(); - config_read_from = Some(config_file_path); - } - // If we have an error deserializing the file defined by the user. - Err(err) if opts.config_file_path.is_some() => anyhow::bail!(err), - _ => (), - } + let opt_from_config = toml::from_slice::(&config)?; + // We inject the values from the toml in the corresponding env vars if needs be. Doing so, we respect the priority toml < env vars < cli args. + opt_from_config.export_to_env(); + // Once injected we parse the cli args once again to take the new env vars into scope. + opts = Opt::parse(); + config_read_from = Some(config_file_path); } // If we have an error while reading the file defined by the user. - Err(err) if opts.config_file_path.is_some() => anyhow::bail!(err), + Err(_) if opts.config_file_path.is_some() => anyhow::bail!( + "unable to open or read the {:?} configuration file.", + opts.config_file_path.unwrap().display().to_string() + ), _ => (), } }