Skip to content

Commit c175fea

Browse files
authored
Remove deprecated Error::description usage (#387)
1 parent 455f33e commit c175fea

File tree

6 files changed

+21
-56
lines changed

6 files changed

+21
-56
lines changed

src/error.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,6 @@ impl Error {
6666
}
6767

6868
impl error::Error for Error {
69-
fn description(&self) -> &str {
70-
use self::ErrorKind::*;
71-
72-
match self.inner {
73-
StatusCode(ref e) => e.description(),
74-
Method(ref e) => e.description(),
75-
Uri(ref e) => e.description(),
76-
UriParts(ref e) => e.description(),
77-
HeaderName(ref e) => e.description(),
78-
HeaderValue(ref e) => e.description(),
79-
}
80-
}
81-
8269
// Return any available cause from the inner error. Note the inner error is
8370
// not itself the cause.
8471
fn source(&self) -> Option<&(dyn error::Error + 'static)> {

src/header/name.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,15 +2003,11 @@ impl fmt::Debug for InvalidHeaderName {
20032003

20042004
impl fmt::Display for InvalidHeaderName {
20052005
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2006-
self.description().fmt(f)
2006+
f.write_str("invalid HTTP header name")
20072007
}
20082008
}
20092009

2010-
impl Error for InvalidHeaderName {
2011-
fn description(&self) -> &str {
2012-
"invalid HTTP header name"
2013-
}
2014-
}
2010+
impl Error for InvalidHeaderName {}
20152011

20162012
// ===== HdrName =====
20172013

src/header/value.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -569,27 +569,19 @@ impl fmt::Debug for InvalidHeaderValue {
569569

570570
impl fmt::Display for InvalidHeaderValue {
571571
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
572-
self.description().fmt(f)
572+
f.write_str("failed to parse header value")
573573
}
574574
}
575575

576-
impl Error for InvalidHeaderValue {
577-
fn description(&self) -> &str {
578-
"failed to parse header value"
579-
}
580-
}
576+
impl Error for InvalidHeaderValue {}
581577

582578
impl fmt::Display for ToStrError {
583579
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
584-
self.description().fmt(f)
580+
f.write_str("failed to convert header to a str")
585581
}
586582
}
587583

588-
impl Error for ToStrError {
589-
fn description(&self) -> &str {
590-
"failed to convert header to a str"
591-
}
592-
}
584+
impl Error for ToStrError {}
593585

594586
// ===== PartialEq / PartialOrd =====
595587

src/method.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,11 @@ impl fmt::Debug for InvalidMethod {
365365

366366
impl fmt::Display for InvalidMethod {
367367
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
368-
write!(f, "{}", self.description())
368+
f.write_str("invalid HTTP method")
369369
}
370370
}
371371

372-
impl Error for InvalidMethod {
373-
fn description(&self) -> &str {
374-
"invalid HTTP method"
375-
}
376-
}
372+
impl Error for InvalidMethod {}
377373

378374
#[test]
379375
fn test_method_eq() {

src/status.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -515,15 +515,11 @@ impl fmt::Debug for InvalidStatusCode {
515515

516516
impl fmt::Display for InvalidStatusCode {
517517
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
518-
f.write_str(self.description())
518+
f.write_str("invalid status code")
519519
}
520520
}
521521

522-
impl Error for InvalidStatusCode {
523-
fn description(&self) -> &str {
524-
"invalid status code"
525-
}
526-
}
522+
impl Error for InvalidStatusCode {}
527523

528524
macro_rules! status_code_strs {
529525
($($num:expr,)+) => {

src/uri/mod.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,14 +1025,8 @@ impl From<ErrorKind> for InvalidUriParts {
10251025
}
10261026
}
10271027

1028-
impl fmt::Display for InvalidUri {
1029-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1030-
self.description().fmt(f)
1031-
}
1032-
}
1033-
1034-
impl Error for InvalidUri {
1035-
fn description(&self) -> &str {
1028+
impl InvalidUri {
1029+
fn s(&self) -> &str {
10361030
match self.0 {
10371031
ErrorKind::InvalidUriChar => "invalid uri character",
10381032
ErrorKind::InvalidScheme => "invalid scheme",
@@ -1049,18 +1043,22 @@ impl Error for InvalidUri {
10491043
}
10501044
}
10511045

1052-
impl fmt::Display for InvalidUriParts {
1046+
impl fmt::Display for InvalidUri {
10531047
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1054-
self.0.fmt(f)
1048+
self.s().fmt(f)
10551049
}
10561050
}
10571051

1058-
impl Error for InvalidUriParts {
1059-
fn description(&self) -> &str {
1060-
self.0.description()
1052+
impl Error for InvalidUri {}
1053+
1054+
impl fmt::Display for InvalidUriParts {
1055+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1056+
self.0.fmt(f)
10611057
}
10621058
}
10631059

1060+
impl Error for InvalidUriParts {}
1061+
10641062
impl Hash for Uri {
10651063
fn hash<H>(&self, state: &mut H)
10661064
where

0 commit comments

Comments
 (0)