Skip to content

Commit 1d61a5c

Browse files
committed
feat(errors): add Error::is_shutdown
1 parent f1b89c1 commit 1d61a5c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/error.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ pub(super) enum Kind {
5656
/// The body write was aborted.
5757
BodyWriteAborted,
5858
/// Error calling AsyncWrite::shutdown()
59-
#[cfg(feature = "http1")]
6059
Shutdown,
6160

6261
/// A general error from h2.
@@ -201,6 +200,11 @@ impl Error {
201200
self.find_source::<TimedOut>().is_some()
202201
}
203202

203+
/// Returns true if the error was caused by a shutdown.
204+
pub fn is_shutdown(&self) -> bool {
205+
matches!(self.inner.kind, Kind::Shutdown)
206+
}
207+
204208
/// Consumes the error, returning its cause.
205209
pub fn into_cause(self) -> Option<Box<dyn StdError + Send + Sync>> {
206210
self.inner.cause
@@ -440,7 +444,6 @@ impl Error {
440444
#[cfg(any(feature = "http1", feature = "http2"))]
441445
Kind::BodyWrite => "error writing a body to connection",
442446
Kind::BodyWriteAborted => "body write aborted",
443-
#[cfg(feature = "http1")]
444447
Kind::Shutdown => "error shutting down connection",
445448
#[cfg(feature = "http2")]
446449
Kind::Http2 => "http2 error",

0 commit comments

Comments
 (0)