Skip to content

Commit 4bfce56

Browse files
committed
fix: Prevent caching client from caching errors
1 parent 9cc4ccd commit 4bfce56

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ pub trait Api: Send + Sync {
15151515
}
15161516
}
15171517

1518-
fn error_on_non_success(status: &StatusCode, body: &[u8]) -> Result<(), Error> {
1518+
pub(crate) fn error_on_non_success(status: &StatusCode, body: &[u8]) -> Result<(), Error> {
15191519
if !status.is_success() {
15201520
return Err(Error::ResponseStatus {
15211521
status: *status,

src/caching_client.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use url::Url;
88

99
use crate::{
1010
Client,
11-
api::{Api, Container, Value},
11+
api::{Api, Container, Value, error_on_non_success},
1212
error::Error,
1313
};
1414

@@ -72,6 +72,8 @@ impl Api for CachingClient {
7272
let fut = async move {
7373
let (body, status) = client.get(url_clone).await?;
7474

75+
error_on_non_success(&status, &body)?;
76+
7577
Ok::<_, Error>((body, status))
7678
};
7779

0 commit comments

Comments
 (0)