Skip to content

Commit

Permalink
Merge pull request #447 from lumeohq/fix-status-panic
Browse files Browse the repository at this point in the history
Fix panic in tokio client when encountering unsupported StatusCode
  • Loading branch information
arlyon authored Oct 5, 2023
2 parents 16fced0 + 9b94228 commit e180a61
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/client/base/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@ async fn send_inner(
StripeError::from(e.error)
})
.unwrap_or_else(StripeError::from);
last_status = Some(status.into());
last_status = Some(
// NOTE: StatusCode::from can panic here, so fall back to InternalServerError
// see https://github.com/http-rs/http-types/blob/ac5d645ce5294554b86ebd49233d3ec01665d1d7/src/hyperium_http.rs#L20-L24
StatusCode::try_from(u16::from(status))
.unwrap_or(StatusCode::InternalServerError),
);
last_retry_header = retry;
continue;
}
Expand Down

0 comments on commit e180a61

Please sign in to comment.