From 5fe9ce8d7b0450d13f22f45ca77de39f367e2acb Mon Sep 17 00:00:00 2001 From: spikecodes <19519553+spikecodes@users.noreply.github.com> Date: Wed, 27 Jan 2021 21:48:32 -0800 Subject: [PATCH] Refactor JSON parsing error logging --- src/utils.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 875ac30..f06eb79 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -459,10 +459,11 @@ pub async fn request(path: String) -> Result { // If response is success Ok(response) => { // Parse the response from Reddit as JSON - match from_str(&response.into_string().unwrap_or_default()) { + let json_string = &response.into_string().unwrap_or_default(); + match from_str(json_string) { Ok(json) => Ok(json), Err(e) => { - println!("{} - Failed to parse page JSON data: {}", url, e); + println!("{} - Failed to parse page JSON data: {} - {}", url, e, json_string); Err("Failed to parse page JSON data".to_string()) } }