diff --git a/src/error.rs b/src/error.rs index e9dc175bdf..dfb200a76a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -56,7 +56,6 @@ pub(super) enum Kind { /// The body write was aborted. BodyWriteAborted, /// Error calling AsyncWrite::shutdown() - #[cfg(feature = "http1")] Shutdown, /// A general error from h2. @@ -201,6 +200,11 @@ impl Error { self.find_source::<TimedOut>().is_some() } + /// Returns true if the error was caused by a shutdown. + pub fn is_shutdown(&self) -> bool { + matches!(self.inner.kind, Kind::Shutdown) + } + /// Consumes the error, returning its cause. pub fn into_cause(self) -> Option<Box<dyn StdError + Send + Sync>> { self.inner.cause @@ -440,7 +444,6 @@ impl Error { #[cfg(any(feature = "http1", feature = "http2"))] Kind::BodyWrite => "error writing a body to connection", Kind::BodyWriteAborted => "body write aborted", - #[cfg(feature = "http1")] Kind::Shutdown => "error shutting down connection", #[cfg(feature = "http2")] Kind::Http2 => "http2 error",