Refactor JSON parsing error logging

This commit is contained in:
spikecodes 2021-01-27 21:48:32 -08:00
parent 8c04365049
commit 5fe9ce8d7b
1 changed files with 3 additions and 2 deletions

View File

@ -459,10 +459,11 @@ pub async fn request(path: String) -> Result<Value, String> {
// 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())
}
}