From 114fe0edb8bac991978e6b7208e965d119191456 Mon Sep 17 00:00:00 2001 From: Henrik Friedrichsen Date: Sun, 17 Mar 2019 16:10:20 +0100 Subject: [PATCH] print playlist cache parsing errors --- src/playlists.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/playlists.rs b/src/playlists.rs index c7e0ae3..4416545 100644 --- a/src/playlists.rs +++ b/src/playlists.rs @@ -48,16 +48,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.playlists.clear(); - store.playlists.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.playlists.clear(); + store.playlists.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); + } } } }