mirror of
https://github.com/openharmony/third_party_rust_http.git
synced 2026-07-18 20:54:29 -04:00
Remove deprecated Error::description usage (#387)
This commit is contained in:
@@ -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)> {
|
||||
|
||||
+2
-6
@@ -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 =====
|
||||
|
||||
|
||||
+4
-12
@@ -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 =====
|
||||
|
||||
|
||||
+2
-6
@@ -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() {
|
||||
|
||||
+2
-6
@@ -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,)+) => {
|
||||
|
||||
+11
-13
@@ -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",
|
||||
@@ -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<H>(&self, state: &mut H)
|
||||
|
||||
Reference in New Issue
Block a user