Skip to content
Draft
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ tokio-util = "0.7.10"

[features]
# Nothing by default
default = ["http3", "server"]
default = ["http3", "http2", "server"]

# Easily turn it all on
full = [
"client",
"http1",
"http2",
"http3",
"server",
]

Expand Down
32 changes: 24 additions & 8 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ pub(super) enum Kind {
/// A general error from h2.
#[cfg(all(any(feature = "client", feature = "server"), feature = "http2"))]
Http2,

/// A general error from h3.
#[cfg(all(any(feature = "client", feature = "server"), feature = "http3"))]
Http3,
}

#[derive(Debug)]
Expand Down Expand Up @@ -452,6 +456,16 @@ impl Error {
}
}

// Apparently the ::h3::Error isn't avaible in the version I'm working with
// #[cfg(all(any(feature = "client", feature = "server"), feature = "http3"))]
// pub(super) fn new_h3(cause: ::h3::Error) -> Error {
// if cause.is_io() {
// Error::new_io(cause.into_io().expect("h3::Error::is_io"))
// } else {
// Error::new(Kind::Http3).with(cause)
// }
// }

fn description(&self) -> &str {
match self.inner.kind {
Kind::Parse(Parse::Method) => "invalid HTTP method parsed",
Expand All @@ -476,7 +490,7 @@ impl Error {
Kind::Parse(Parse::Header(Header::TransferEncodingUnexpected)) => {
"unexpected transfer-encoding parsed"
}
#[cfg(any(feature = "http1", feature = "http2"))]
#[cfg(any(feature = "http1", feature = "http2", feature = "http3"))]
Kind::Parse(Parse::TooLarge) => "message head is too large",
Kind::Parse(Parse::Status) => "invalid HTTP status-code parsed",
#[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))]
Expand All @@ -487,6 +501,7 @@ impl Error {
Kind::IncompleteMessage => "connection closed before message completed",
#[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))]
Kind::UnexpectedMessage => "received unexpected message from connection",
// TODO: check if this cfg needs to be changed
#[cfg(any(
all(feature = "http1", any(feature = "client", feature = "server")),
all(feature = "http2", feature = "client")
Expand All @@ -497,12 +512,12 @@ impl Error {
Kind::HeaderTimeout => "read header from client timeout",
#[cfg(all(
any(feature = "client", feature = "server"),
any(feature = "http1", feature = "http2")
any(feature = "http1", feature = "http2", feature = "http3")
))]
Kind::Body => "error reading a body from connection",
#[cfg(all(
any(feature = "client", feature = "server"),
any(feature = "http1", feature = "http2")
any(feature = "http1", feature = "http2", feature = "http3")
))]
Kind::BodyWrite => "error writing a body to connection",
#[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))]
Expand All @@ -511,13 +526,12 @@ impl Error {
Kind::Http2 => "http2 error",
#[cfg(all(
any(feature = "client", feature = "server"),
any(feature = "http1", feature = "http2")
any(feature = "http1", feature = "http2", feature = "http3")
))]
Kind::Io => "connection error",

#[cfg(all(
any(feature = "client", feature = "server"),
any(feature = "http1", feature = "http2")
any(feature = "http1", feature = "http2", feature = "http3")
))]
Kind::User(User::Body) => "error from user's Body stream",
#[cfg(any(
Expand All @@ -531,10 +545,10 @@ impl Error {
}
#[cfg(any(
all(any(feature = "client", feature = "server"), feature = "http1"),
all(feature = "server", feature = "http2")
all(feature = "server", feature = "http2", feature = "http3")
))]
Kind::User(User::Service) => "error from user's Service",
#[cfg(any(feature = "http1", feature = "http2"))]
#[cfg(any(feature = "http1", feature = "http2", feature = "http3"))]
#[cfg(feature = "server")]
Kind::User(User::UnexpectedHeader) => "user sent unexpected header",
#[cfg(feature = "http1")]
Expand All @@ -549,6 +563,8 @@ impl Error {
Kind::User(User::DispatchGone) => "dispatch task is gone",
#[cfg(feature = "ffi")]
Kind::User(User::AbortedByCallback) => "operation aborted by an application callback",
#[cfg(all(any(feature = "client", feature = "server"), feature = "http3"))]
Kind::Http3 => "http3 error",
}
}
}
Expand Down
Loading
Loading