Skip to content
This repository was archived by the owner on Jul 6, 2024. It is now read-only.

Commit e355c11

Browse files
committed
fix: Order of reqwest error handling
Inspect timeout errors first as they can originate from other locations. In this particular case a request timeout would always return an unexpected EOF since we handled body errors before timeout.
1 parent 472d790 commit e355c11

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "proton-api-rs"
33
authors = ["Leander Beernaert <lbb-dev@pm.me>"]
4-
version = "0.5.2"
4+
version = "0.5.3"
55
edition = "2021"
66
license = "AGPL-3.0-only"
77
description = "Unofficial implemention of proton REST API in rust"

src/client/http_client/reqwest_client.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ impl From<reqwest::Error> for RequestError {
180180

181181
impl From<reqwest::Error> for HttpClientError {
182182
fn from(value: reqwest::Error) -> Self {
183+
// Check timeout before all other errors as it can be produced by multiple
184+
// reqwest error kinds.
185+
if value.is_timeout() {
186+
return HttpClientError::Timeout(anyhow::Error::new(value));
187+
}
188+
183189
#[cfg(not(target_arch = "wasm32"))]
184190
if value.is_connect() {
185191
return HttpClientError::Connection(anyhow::Error::new(value));
@@ -195,8 +201,6 @@ impl From<reqwest::Error> for HttpClientError {
195201
.unwrap_or("Unknown URL".to_string()),
196202
anyhow::Error::new(value),
197203
)
198-
} else if value.is_timeout() {
199-
HttpClientError::Timeout(anyhow::Error::new(value))
200204
} else if value.is_request() {
201205
HttpClientError::Request(anyhow::Error::new(value))
202206
} else {

0 commit comments

Comments
 (0)