Add is_connect on error (#1023)
* error: add is_connect helper function * test: ensure request_timeout is not connect_timeout * fmt * skip err is_connect if target_arch is wasm. rerun checks Co-authored-by: lishuo <lishuo.03@bytedance.com> Co-authored-by: Sean McArthur <sean@seanmonstar.com>
This commit is contained in:
18
src/error.rs
18
src/error.rs
@@ -102,6 +102,24 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
/// Returns true if the error is related to connect
|
||||
pub fn is_connect(&self) -> bool {
|
||||
let mut source = self.source();
|
||||
|
||||
while let Some(err) = source {
|
||||
if let Some(hyper_err) = err.downcast_ref::<hyper::Error>() {
|
||||
if hyper_err.is_connect() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
source = err.source();
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
/// Returns true if the error is related to the request or response body
|
||||
pub fn is_body(&self) -> bool {
|
||||
match self.inner.kind {
|
||||
|
||||
Reference in New Issue
Block a user