From 588e3c01025f23141a2485ae16150bf32e2b0df1 Mon Sep 17 00:00:00 2001 From: Luke D Jones Date: Thu, 22 Oct 2020 08:28:12 +1300 Subject: [PATCH] Panic if config file is bad --- asus-nb-ctrl/src/config.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/asus-nb-ctrl/src/config.rs b/asus-nb-ctrl/src/config.rs index 3507eea3..3b48604b 100644 --- a/asus-nb-ctrl/src/config.rs +++ b/asus-nb-ctrl/src/config.rs @@ -30,18 +30,18 @@ impl Config { .write(true) .create(true) .open(&CONFIG_PATH) - .expect(&format!("The file {} or directory /etc/asusd/ is missing", CONFIG_PATH)); // 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 { self = Config::create_default(&mut file, &supported_led_modes); } else { self = serde_json::from_str(&buf).unwrap_or_else(|_| { - warn!( - "Could not deserialise {}. Overwriting with default", - CONFIG_PATH - ); - Config::create_default(&mut file, &supported_led_modes) + warn!("Could not deserialise {}", CONFIG_PATH); + panic!("Please remove {} then restart asusd", CONFIG_PATH); }); } }