From 05c53df0edb3e2366fcf9f8aba5f70d998b5db5a Mon Sep 17 00:00:00 2001 From: Luke D Jones Date: Wed, 23 Sep 2020 21:24:25 +1200 Subject: [PATCH] Better description of config panic --- asus-nb-ctrl/src/config.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/asus-nb-ctrl/src/config.rs b/asus-nb-ctrl/src/config.rs index 1cd37f6b..7b0d690e 100644 --- a/asus-nb-ctrl/src/config.rs +++ b/asus-nb-ctrl/src/config.rs @@ -23,15 +23,14 @@ pub struct Config { } impl Config { - /// `load` will attempt to read the config, but if it is not found it - /// will create a new default config and write that out. + /// `load` will attempt to read the config, and panic if the dir is missing pub fn load(mut self, supported_led_modes: &[u8]) -> Self { let mut file = OpenOptions::new() .read(true) .write(true) .create(true) .open(&CONFIG_PATH) - .unwrap(); // okay to cause panic here + .expect(&format!("The file {} or directory /etc/asusd/ is missing", CONFIG_PATH)); // okay to cause panic here let mut buf = String::new(); if let Ok(l) = file.read_to_string(&mut buf) { if l == 0 {