Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

replace vestigial unwraps with proper error reporting #14

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions capture/src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@ pub async fn event(
"application/x-www-form-urlencoded" => {
tracing::Span::current().record("content_type", "application/x-www-form-urlencoded");

let input: EventFormData = serde_urlencoded::from_bytes(body.deref()).unwrap();
let input: EventFormData = serde_urlencoded::from_bytes(body.deref()).map_err(|e| {
tracing::error!("failed to decode body: {}", e);
CaptureError::RequestDecodingError(String::from("invalid form data"))
})?;
let payload = base64::engine::general_purpose::STANDARD
.decode(input.data)
.unwrap();
.map_err(|e| {
tracing::error!("failed to decode form data: {}", e);
CaptureError::RequestDecodingError(String::from("missing data field"))
})?;
RawEvent::from_bytes(payload.into())
}
ct => {
Expand Down
Loading