Skip to content

Commit 3eeb04e

Browse files
committed
feat: add Error::is_shutdown()
Benchmarking tools often cause connections to be ungracefully shutdown. This makes it possible to filter these errors out. Replaces #2745
1 parent 68bae2b commit 3eeb04e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/error.rs

+7
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ impl Error {
238238
matches!(self.inner.kind, Kind::User(User::BodyWriteAborted))
239239
}
240240

241+
/// Returns true if the error was caused while calling `AsyncWrite::shutdown()`.
242+
pub fn is_shutdown(&self) -> bool {
243+
#[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))]
244+
return matches!(self.inner.kind, Kind::Shutdown);
245+
false
246+
}
247+
241248
/// Returns true if the error was caused by a timeout.
242249
pub fn is_timeout(&self) -> bool {
243250
#[cfg(all(feature = "http1", feature = "server"))]

0 commit comments

Comments
 (0)