Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ impl Error {
if err.is::<TimedOut>() {
return true;
}
if let Some(err) = err.downcast_ref::<Error>() {
if err.is_timeout() {
return true;
}
}
#[cfg(not(all(
target_arch = "wasm32",
any(target_os = "unknown", target_os = "none")
Expand Down Expand Up @@ -500,6 +505,23 @@ mod tests {
}
}

#[test]
fn decode_body_timeout_is_timeout() {
// A body timeout surfaced while decoding stays a decode error, but
// is_timeout still finds the timeout in the source chain.
let err = super::decode(super::body(super::TimedOut));
assert!(err.is_decode());
assert!(err.is_timeout());
}

#[test]
fn decode_wraps_other_errors() {
let io = io::Error::new(io::ErrorKind::Other, "boom");
let err = super::decode(io);
assert!(err.is_decode());
assert!(!err.is_timeout());
}

#[test]
fn is_timeout() {
let err = super::request(super::TimedOut);
Expand Down