pub struct Error { /* private fields */ }Expand description
Represents errors that can occur handling HTTP streams.
§Formatting
The Display implementation of this type will only print the details of
this level of error, even though it may have been caused by another error
and contain that error in its source. To print all the relevant
information, including the source chain, using something like
std::error::Report, or equivalent 3rd party types.
The contents of the formatted error message of this specific Error type
is unspecified. You must not depend on it. The wording and details may
change in any version, with the goal of improving error messages.
§Source
A hyper::Error may be caused by another error. To aid in debugging,
those are exposed in Error::source() as erased types. While it is
possible to check the exact type of the sources, they can not be depended
on. They may come from private internal dependencies, and are subject to
change at any moment.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_parse(&self) -> bool
pub fn is_parse(&self) -> bool
Returns true if this was an HTTP parse error.
This can be caused by a malformed HTTP message, an invalid header,
an invalid URI, an invalid HTTP version, or a message head that is
too large. Use the more specific is_parse_* methods to determine
the exact cause.
Sourcepub fn is_parse_too_large(&self) -> bool
Available on crate features http1 and server only.
pub fn is_parse_too_large(&self) -> bool
http1 and server only.Returns true if this was an HTTP parse error caused by a message that was too large.
This is triggered when the message head (request line plus headers for
HTTP/1, or header frame for HTTP/2) exceeds the configured
max_buf_size.
It also covers the case where the URI alone exceeds the internal
maximum URI length.
Sourcepub fn is_parse_status(&self) -> bool
pub fn is_parse_status(&self) -> bool
Returns true if this was an HTTP parse error caused by an invalid response status code or reason phrase.
Sourcepub fn is_parse_version_h2(&self) -> bool
Available on (crate features client or server) and crate feature http1 only.
pub fn is_parse_version_h2(&self) -> bool
client or server) and crate feature http1 only.Returns true if this was an HTTP parse error caused by HTTP2 preface sent over an HTTP1 connection.
This can happen when a client sends an HTTP/2 connection preface to a server that is only expecting HTTP/1.x requests.
Sourcepub fn is_user(&self) -> bool
pub fn is_user(&self) -> bool
Returns true if this error was caused by user code.
For example, this can be returned when the user’s Service returns
an error, the user’s Body stream yields an error, or the user
sends an unexpected header combination (such as both
content-length and transfer-encoding).
Sourcepub fn is_canceled(&self) -> bool
pub fn is_canceled(&self) -> bool
Returns true if this was about a Request that was canceled.
This typically happens when a pending request is dropped before it can be dispatched to the connection, for example because the connection was not ready.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Returns true if a sender’s channel is closed.
This can occur when the other side of a client or body channel has been dropped, indicating that the receiver is no longer interested in the data.
Sourcepub fn is_incomplete_message(&self) -> bool
pub fn is_incomplete_message(&self) -> bool
Returns true if the connection closed before a message could complete.
This means that the supplied IO connection reported EOF (closed) while hyper’s HTTP state indicates more of the message (either request or response) needed to be transmitted.
Some cases this could happen (not exhaustive):
- A request is written on a connection, and the next
readreports EOF (perhaps a server just closed an “idle” connection). - A message body is only partially receive before the connection reports EOF.
- A client writes a request to your server, and then closes the write
half while waiting for your response. If you need to support this,
consider enabling
half_close.
Sourcepub fn is_body_write_aborted(&self) -> bool
pub fn is_body_write_aborted(&self) -> bool
Returns true if the body write was aborted.
This occurs when the user’s code explicitly aborts writing of the outgoing body before it completes, for example by dropping the body sender.
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Returns true if the error was caused while calling AsyncWrite::shutdown().
This can happen when the connection is being gracefully shut down and the underlying IO reports an error during the shutdown sequence.
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Returns true if the error was caused by a timeout.
For HTTP/1 servers, this includes the header read timeout (see
header_read_timeout).
It also covers any timeout set via a user-provided timer.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()