From 01c541e2bb435a4ec63e5e1f712f779c7c9ef061 Mon Sep 17 00:00:00 2001 From: iff Date: Thu, 12 Dec 2024 19:18:52 +0100 Subject: [PATCH] chore: always show raw body on parse failure --- module-request-ai/src/requests.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/module-request-ai/src/requests.rs b/module-request-ai/src/requests.rs index fa0ec50..858ef71 100644 --- a/module-request-ai/src/requests.rs +++ b/module-request-ai/src/requests.rs @@ -153,7 +153,7 @@ The command `{last_command}` returns the following error message: `{error_msg}`. if let Ok(json) = json { json } else { - eprintln!("Failed to parse JSON response: {}", res); + eprintln!("AI module: Failed to parse JSON response: {}", res); return None; } }; @@ -164,12 +164,13 @@ The command `{last_command}` returns the following error message: `{error_msg}`. let str = { let str = content.as_str(); str?; - str.expect("Failed to get content from response") + str.expect("AI module: Failed to get content from response") .trim_start_matches("```") .trim_end_matches("```") }; let json = serde_json::from_str(str); if json.is_err() { + eprintln!("AI module: Failed to parse JSON content: {}", str); return None; } json.unwrap()