Skip to content

Commit

Permalink
Convert hard error to warn on mismatched status code (#2965)
Browse files Browse the repository at this point in the history
Closes #2934.
  • Loading branch information
GnomedDev committed Sep 1, 2024
1 parent acb1f7b commit 3fb1f37
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use reqwest::Url;
use reqwest::{Client, ClientBuilder, Response as ReqwestResponse, StatusCode};
use secrecy::{ExposeSecret, SecretString};
use serde::de::DeserializeOwned;
use tracing::{debug, instrument, trace};
use tracing::{debug, instrument, warn};

use super::multipart::{Multipart, MultipartUpload};
use super::ratelimiting::Ratelimiter;
Expand Down Expand Up @@ -4926,16 +4926,21 @@ impl Http {
/// This is a function that performs a light amount of work and returns an empty tuple, so it's
/// called "self.wind" to denote that it's lightweight.
pub(super) async fn wind(&self, expected: u16, req: Request<'_>) -> Result<()> {
let route = req.route;
let method = req.method.reqwest_method();
let response = self.request(req).await?;

if response.status().as_u16() == expected {
if response.status().is_success() {
let response_status = response.status().as_u16();
if response_status != expected {
let route = route.path();
warn!("Mismatched successful response status from {route}! Expected {expected} but got {response_status}");
}

return Ok(());
}

debug!("Expected {}, got {}", expected, response.status());
trace!("Unsuccessful response: {:?}", response);

debug!("Unsuccessful response: {response:?}");
Err(Error::Http(HttpError::UnsuccessfulRequest(
ErrorResponse::from_response(response, method).await,
)))
Expand Down

0 comments on commit 3fb1f37

Please sign in to comment.