From 6932896a7fca58fe461269461f925da8fd4e8d8a Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Sat, 5 Feb 2022 02:10:00 +0100 Subject: [PATCH] feat(error): add `Error::message` (#2737) 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 --- src/error.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/error.rs b/src/error.rs index e9dc175bdf..265f9172dc 100644 --- a/src/error.rs +++ b/src/error.rs @@ -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",