We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1f190c6 + 859ba86 commit 1a24606Copy full SHA for 1a24606
src/v1/api.rs
@@ -187,8 +187,13 @@ impl OpenAIClient {
187
) -> Result<T, APIError> {
188
let status = response.status();
189
if status.is_success() {
190
- let parsed = response.json::<T>().await?;
191
- Ok(parsed)
+ let text = response.text().await.unwrap_or_else(|_| "".to_string());
+ match serde_json::from_str::<T>(&text) {
192
+ Ok(parsed) => Ok(parsed),
193
+ Err(e) => Err(APIError::CustomError {
194
+ message: format!("Failed to parse JSON: {} / response {}", e, text),
195
+ }),
196
+ }
197
} else {
198
let error_message = response
199
.text()
0 commit comments