From b2505ce0860f9d8ac073b3e09e57d9f9d07aaeb8 Mon Sep 17 00:00:00 2001 From: Alex Page Date: Sat, 18 Mar 2023 02:40:07 -0400 Subject: [PATCH] Log JSON parsing errors --- src/commands.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/commands.rs b/src/commands.rs index e87b1c4..647b213 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -91,7 +91,27 @@ pub async fn play( let mut handler = handler_lock.lock().await; debug!("Trying to play: {}", url); - let source = songbird::ytdl(&url).await?; + let source = songbird::ytdl(&url).await; + + let source = match source { + Ok(source) => source, + Err(e) => { + match e { + songbird::input::error::Error::Json { + ref error, + ref parsed_text, + } => { + debug!("Failed to play: {}", error); + debug!("Parsed text: {}", parsed_text); + } + _ => { + debug!("Failed to play: {}", e); + } + } + return Err(Box::new(e)); + } + }; + debug!("Playing: {:?}", source.metadata); let title = source .metadata