VdfValue::into_vec: better error handling
This commit is contained in:
parent
3e6d025b74
commit
0a4a401953
|
@ -149,6 +149,7 @@ fn get_shortcuts(path: PathBuf) -> Result<Vec<NonSteamGame>, String> {
|
|||
let vec: Result<Vec<NonSteamGame>, 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 {
|
||||
|
|
|
@ -28,12 +28,12 @@ pub enum VdfValue {
|
|||
}
|
||||
|
||||
impl VdfValue {
|
||||
pub fn into_vec(self) -> Vec<VdfValue> {
|
||||
pub fn into_vec(self) -> Option<Vec<VdfValue>> {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue