-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Since reqwest 0.12.1 (seanmonstar/reqwest#2199), fmt::Display for reqwest::Error no longer includes the source. The whole reason for WrappedReqwestError was to avoid displaying the source twice. But since the above change, the source isn't displayed at all. After this change, dfx will once again display the error source(s) for request::Error, but on separate lines ("Caused by:") like other error sources.
- Loading branch information
1 parent
349d547
commit 29d902c
Showing
8 changed files
with
28 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,16 @@ | ||
use crate::http::retryable::Retryable; | ||
use reqwest::StatusCode; | ||
use thiserror::Error; | ||
|
||
// reqwest::Error's fmt::Display appends the error descriptions of all sources. | ||
// For this reason, it is not marked as #[source] here, so that we don't | ||
// display the error descriptions of all sources repeatedly. | ||
#[derive(Error, Debug)] | ||
#[error("{}", .0)] | ||
pub struct WrappedReqwestError(pub reqwest::Error); | ||
|
||
impl Retryable for WrappedReqwestError { | ||
fn is_retryable(&self) -> bool { | ||
let err = &self.0; | ||
err.is_timeout() | ||
|| err.is_connect() | ||
|| matches!( | ||
err.status(), | ||
Some( | ||
StatusCode::INTERNAL_SERVER_ERROR | ||
| StatusCode::BAD_GATEWAY | ||
| StatusCode::SERVICE_UNAVAILABLE | ||
| StatusCode::GATEWAY_TIMEOUT | ||
| StatusCode::TOO_MANY_REQUESTS | ||
) | ||
pub fn is_retryable(err: &reqwest::Error) -> bool { | ||
err.is_timeout() | ||
|| err.is_connect() | ||
|| matches!( | ||
err.status(), | ||
Some( | ||
StatusCode::INTERNAL_SERVER_ERROR | ||
| StatusCode::BAD_GATEWAY | ||
| StatusCode::SERVICE_UNAVAILABLE | ||
| StatusCode::GATEWAY_TIMEOUT | ||
| StatusCode::TOO_MANY_REQUESTS | ||
) | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
pub mod get; | ||
pub mod retryable; |
This file was deleted.
Oops, something went wrong.