Skip to content

Commit 8b81372

Browse files
authored
Derive PartialEq for all types; Log all deserialization errors (#64)
* derive PartialEq for all types in types.rs * log deserialization error * log deserialization error
1 parent c27e964 commit 8b81372

File tree

2 files changed

+60
-58
lines changed

2 files changed

+60
-58
lines changed

async-openai/src/client.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ impl Client {
232232
return Err(OpenAIError::ApiError(wrapped_error.error));
233233
}
234234

235-
let response: O =
236-
serde_json::from_slice(bytes.as_ref()).map_err(OpenAIError::JSONDeserialize)?;
235+
let response: O = serde_json::from_slice(bytes.as_ref())
236+
.map_err(|e| map_deserialization_error(e, bytes.as_ref()))?;
237237
Ok(response)
238238
}
239239

@@ -369,7 +369,9 @@ impl Client {
369369
}
370370

371371
let response = match serde_json::from_str::<O>(&message.data) {
372-
Err(e) => Err(OpenAIError::JSONDeserialize(e)),
372+
Err(e) => {
373+
Err(map_deserialization_error(e, &message.data.as_bytes()))
374+
}
373375
Ok(output) => Ok(output),
374376
};
375377

0 commit comments

Comments
 (0)