diff --git a/src/playlists.rs b/src/playlists.rs index fbd5f41..4577799 100644 --- a/src/playlists.rs +++ b/src/playlists.rs @@ -72,16 +72,19 @@ impl Playlists { cache_path.to_str().unwrap() ); let parsed: Result = serde_json::from_str(&contents); - if let Ok(cache) = parsed { - debug!("playlist cache loaded ({} lists)", cache.playlists.len()); - let mut store = self.store.write().expect("can't writelock playlist store"); - store.clear(); - store.extend(cache.playlists); + match parsed { + Ok(cache) => { + debug!("playlist cache loaded ({} lists)", cache.playlists.len()); + let mut store = self.store.write().expect("can't writelock playlist store"); + store.clear(); + store.extend(cache.playlists); - // force refresh of UI (if visible) - self.ev.send(Event::ScreenChange("playlists".to_owned())); - } else { - error!("playlist cache corrupted?"); + // force refresh of UI (if visible) + self.ev.send(Event::ScreenChange("playlists".to_owned())); + }, + Err(e) => { + error!("can't parse playlist cache: {}", e); + } } } }