diff --git a/src/error.rs b/src/error.rs index 3b31a10..ba69084 100644 --- a/src/error.rs +++ b/src/error.rs @@ -66,19 +66,6 @@ impl Error { } impl error::Error for Error { - fn description(&self) -> &str { - use self::ErrorKind::*; - - match self.inner { - StatusCode(ref e) => e.description(), - Method(ref e) => e.description(), - Uri(ref e) => e.description(), - UriParts(ref e) => e.description(), - HeaderName(ref e) => e.description(), - HeaderValue(ref e) => e.description(), - } - } - // Return any available cause from the inner error. Note the inner error is // not itself the cause. fn source(&self) -> Option<&(dyn error::Error + 'static)> { diff --git a/src/header/name.rs b/src/header/name.rs index 8e871ec..4d70ff3 100644 --- a/src/header/name.rs +++ b/src/header/name.rs @@ -2003,15 +2003,11 @@ impl fmt::Debug for InvalidHeaderName { impl fmt::Display for InvalidHeaderName { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.description().fmt(f) + f.write_str("invalid HTTP header name") } } -impl Error for InvalidHeaderName { - fn description(&self) -> &str { - "invalid HTTP header name" - } -} +impl Error for InvalidHeaderName {} // ===== HdrName ===== diff --git a/src/header/value.rs b/src/header/value.rs index c3096a1..4a765af 100644 --- a/src/header/value.rs +++ b/src/header/value.rs @@ -569,27 +569,19 @@ impl fmt::Debug for InvalidHeaderValue { impl fmt::Display for InvalidHeaderValue { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.description().fmt(f) + f.write_str("failed to parse header value") } } -impl Error for InvalidHeaderValue { - fn description(&self) -> &str { - "failed to parse header value" - } -} +impl Error for InvalidHeaderValue {} impl fmt::Display for ToStrError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.description().fmt(f) + f.write_str("failed to convert header to a str") } } -impl Error for ToStrError { - fn description(&self) -> &str { - "failed to convert header to a str" - } -} +impl Error for ToStrError {} // ===== PartialEq / PartialOrd ===== diff --git a/src/method.rs b/src/method.rs index 6a8ed14..6f1776c 100644 --- a/src/method.rs +++ b/src/method.rs @@ -365,15 +365,11 @@ impl fmt::Debug for InvalidMethod { impl fmt::Display for InvalidMethod { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.description()) + f.write_str("invalid HTTP method") } } -impl Error for InvalidMethod { - fn description(&self) -> &str { - "invalid HTTP method" - } -} +impl Error for InvalidMethod {} #[test] fn test_method_eq() { diff --git a/src/status.rs b/src/status.rs index 5b4c41f..903bd82 100644 --- a/src/status.rs +++ b/src/status.rs @@ -515,15 +515,11 @@ impl fmt::Debug for InvalidStatusCode { impl fmt::Display for InvalidStatusCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.description()) + f.write_str("invalid status code") } } -impl Error for InvalidStatusCode { - fn description(&self) -> &str { - "invalid status code" - } -} +impl Error for InvalidStatusCode {} macro_rules! status_code_strs { ($($num:expr,)+) => { diff --git a/src/uri/mod.rs b/src/uri/mod.rs index 066a966..716ea1a 100644 --- a/src/uri/mod.rs +++ b/src/uri/mod.rs @@ -1025,14 +1025,8 @@ impl From for InvalidUriParts { } } -impl fmt::Display for InvalidUri { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.description().fmt(f) - } -} - -impl Error for InvalidUri { - fn description(&self) -> &str { +impl InvalidUri { + fn s(&self) -> &str { match self.0 { ErrorKind::InvalidUriChar => "invalid uri character", ErrorKind::InvalidScheme => "invalid scheme", @@ -1049,17 +1043,21 @@ impl Error for InvalidUri { } } +impl fmt::Display for InvalidUri { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.s().fmt(f) + } +} + +impl Error for InvalidUri {} + impl fmt::Display for InvalidUriParts { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } -impl Error for InvalidUriParts { - fn description(&self) -> &str { - self.0.description() - } -} +impl Error for InvalidUriParts {} impl Hash for Uri { fn hash(&self, state: &mut H)