Skip to content

Commit 4b04208

Browse files
committed
return string which failed deserialiaztion
1 parent 3fe2547 commit 4b04208

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

async-openai/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ pub enum WebhookError {
3535
#[error("invalid webhook signature: {0}")]
3636
InvalidSignature(String),
3737
/// Failed to deserialize webhook payload
38-
#[error("failed to deserialize webhook payload: {0}")]
39-
Deserialization(#[from] serde_json::Error),
38+
#[error("failed to deserialize webhook payload: error:{0} content:{1}")]
39+
Deserialization(serde_json::Error, String),
4040
}
4141

4242
#[derive(Debug, thiserror::Error)]

async-openai/src/webhooks.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ impl Webhooks {
4848
)?;
4949

5050
// Deserialize the event
51-
let event: WebhookEvent = serde_json::from_str(body)?;
51+
let event: WebhookEvent = serde_json::from_str(body)
52+
.map_err(|e| WebhookError::Deserialization(e, body.to_string()))?;
5253

5354
Ok(event)
5455
}

0 commit comments

Comments
 (0)