Skip to content

Commit

Permalink
feat(error): add Error::message (#2737)
Browse files Browse the repository at this point in the history
This adds Error::message which returns the message that is unique to the error, without the message from the source. That way users can create a newtype around hyper::Error and use this in the Display impl to work around #2732.

Closes #2732
  • Loading branch information
davidpdrsn committed Feb 5, 2022
1 parent dcdd6d1 commit 6932896
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/error.rs
Expand Up @@ -396,6 +396,11 @@ impl Error {
}
}

/// The error's standalone message, without the message from the source.
pub fn message(&self) -> impl fmt::Display + '_ {
self.description()
}

fn description(&self) -> &str {
match self.inner.kind {
Kind::Parse(Parse::Method) => "invalid HTTP method parsed",
Expand Down

0 comments on commit 6932896

Please sign in to comment.