Skip to content

Commit b8affd8

Browse files
authored
feat(error): add Error::is_shutdown() (#3863)
Benchmarking tools often cause connections to be ungracefully shutdown. This makes it possible to filter these errors out. Closes #2745
1 parent c88df78 commit b8affd8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/error.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,15 @@ impl Error {
241241
matches!(self.inner.kind, Kind::User(User::BodyWriteAborted))
242242
}
243243

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

0 commit comments

Comments
 (0)