Skip to content
Merged
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
13 changes: 0 additions & 13 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)> {
Expand Down
8 changes: 2 additions & 6 deletions src/header/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =====

Expand Down
16 changes: 4 additions & 12 deletions src/header/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =====

Expand Down
8 changes: 2 additions & 6 deletions src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 2 additions & 6 deletions src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,)+) => {
Expand Down
24 changes: 11 additions & 13 deletions src/uri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,14 +1025,8 @@ impl From<ErrorKind> 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",
Expand All @@ -1049,18 +1043,22 @@ impl Error for InvalidUri {
}
}

impl fmt::Display for InvalidUriParts {
impl fmt::Display for InvalidUri {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
self.s().fmt(f)
}
}

impl Error for InvalidUriParts {
fn description(&self) -> &str {
self.0.description()
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 {}

impl Hash for Uri {
fn hash<H>(&self, state: &mut H)
where
Expand Down