From 96d7483d318c4729f4a47a998c6bb9c7380a6729 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Mon, 20 Sep 2021 17:01:27 -0700 Subject: [PATCH] More descriptive errors when failing to parse a config file --- src/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index 860488d..e25d3ab 100644 --- a/src/config.rs +++ b/src/config.rs @@ -37,9 +37,9 @@ pub fn read_config_from_file() -> Result { let config_path = get_config_path(); let contents = fs::read_to_string(&config_path) - .map_err(|_| format!("Failed to open config file at {}", config_path))?; + .map_err(|err| format!("Failed to open config file at {}: {}", config_path, err))?; let config: Config = toml::from_str(contents.as_str()) - .map_err(|_| format!("Failed to parse config file at {}", config_path))?; + .map_err(|err| format!("Failed to parse config file at {}: {}", config_path, err))?; println!("Config read from file at {}", config_path); Ok(config)