diff --git a/src/main.rs b/src/main.rs index b530733..8ffcfce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -149,6 +149,7 @@ fn get_shortcuts(path: PathBuf) -> Result, String> { let vec: Result, String> = vdf_map["shortcuts"] .clone() .into_vec() + .map_or_else(|| Err("Malformed shortcuts.vdf".to_owned()), Ok)? .into_iter() .map(|x| { if let vdf::VdfValue::Dict(dict) = x { diff --git a/src/vdf.rs b/src/vdf.rs index 50c56e3..10aeb32 100644 --- a/src/vdf.rs +++ b/src/vdf.rs @@ -28,12 +28,12 @@ pub enum VdfValue { } impl VdfValue { - pub fn into_vec(self) -> Vec { + pub fn into_vec(self) -> Option> { if let VdfValue::Dict(dict) = self { // lazily assuming this is an array of strings - dict.into_values().collect() + Some(dict.into_values().collect()) } else { - panic!("Not a Dict! (maybe this should be less brutal of error mgmt!)"); + None } } }