Skip to content

Commit 4cb2866

Browse files
authored
fix: Error::is_timeout() checks for hyper::Error::is_timeout() (#2742)
1 parent 1794d99 commit 4cb2866

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/error.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ impl Error {
120120
if err.is::<TimedOut>() {
121121
return true;
122122
}
123+
#[cfg(not(target_arch = "wasm32"))]
124+
if let Some(hyper_err) = err.downcast_ref::<hyper::Error>() {
125+
if hyper_err.is_timeout() {
126+
return true;
127+
}
128+
}
123129
if let Some(io) = err.downcast_ref::<io::Error>() {
124130
if io.kind() == io::ErrorKind::TimedOut {
125131
return true;
@@ -453,7 +459,9 @@ mod tests {
453459
let err = super::request(super::TimedOut);
454460
assert!(err.is_timeout());
455461

456-
let io = io::Error::new(io::ErrorKind::Other, err);
462+
// todo: test `hyper::Error::is_timeout` when we can easily construct one
463+
464+
let io = io::Error::from(io::ErrorKind::TimedOut);
457465
let nested = super::request(io);
458466
assert!(nested.is_timeout());
459467
}

0 commit comments

Comments
 (0)