Better description of config panic

This commit is contained in:
Luke D Jones
2020-09-23 21:24:25 +12:00
parent a7419cbc4c
commit 05c53df0ed

View File

@@ -23,15 +23,14 @@ pub struct Config {
} }
impl Config { impl Config {
/// `load` will attempt to read the config, but if it is not found it /// `load` will attempt to read the config, and panic if the dir is missing
/// will create a new default config and write that out.
pub fn load(mut self, supported_led_modes: &[u8]) -> Self { pub fn load(mut self, supported_led_modes: &[u8]) -> Self {
let mut file = OpenOptions::new() let mut file = OpenOptions::new()
.read(true) .read(true)
.write(true) .write(true)
.create(true) .create(true)
.open(&CONFIG_PATH) .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(); let mut buf = String::new();
if let Ok(l) = file.read_to_string(&mut buf) { if let Ok(l) = file.read_to_string(&mut buf) {
if l == 0 { if l == 0 {