refactor(error): remove deprecated 'Error::description' method (#2092)
This commit is contained in:
		
				
					committed by
					
						 Sean McArthur
						Sean McArthur
					
				
			
			
				
	
			
			
			
						parent
						
							fb90d30c02
						
					
				
				
					commit
					0f13719873
				
			
							
								
								
									
										46
									
								
								src/error.rs
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								src/error.rs
									
									
									
									
									
								
							| @@ -276,30 +276,7 @@ impl Error { | ||||
|             Error::new(Kind::Http2).with(cause) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl fmt::Debug for Error { | ||||
|     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||||
|         let mut f = f.debug_tuple("hyper::Error"); | ||||
|         f.field(&self.inner.kind); | ||||
|         if let Some(ref cause) = self.inner.cause { | ||||
|             f.field(cause); | ||||
|         } | ||||
|         f.finish() | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl fmt::Display for Error { | ||||
|     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||||
|         if let Some(ref cause) = self.inner.cause { | ||||
|             write!(f, "{}: {}", self.description(), cause) | ||||
|         } else { | ||||
|             f.write_str(self.description()) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl StdError for Error { | ||||
|     fn description(&self) -> &str { | ||||
|         match self.inner.kind { | ||||
|             Kind::Parse(Parse::Method) => "invalid HTTP method parsed", | ||||
| @@ -338,7 +315,30 @@ impl StdError for Error { | ||||
|             Kind::User(User::ManualUpgrade) => "upgrade expected but low level API in use", | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl fmt::Debug for Error { | ||||
|     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||||
|         let mut f = f.debug_tuple("hyper::Error"); | ||||
|         f.field(&self.inner.kind); | ||||
|         if let Some(ref cause) = self.inner.cause { | ||||
|             f.field(cause); | ||||
|         } | ||||
|         f.finish() | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl fmt::Display for Error { | ||||
|     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||||
|         if let Some(ref cause) = self.inner.cause { | ||||
|             write!(f, "{}: {}", self.description(), cause) | ||||
|         } else { | ||||
|             f.write_str(self.description()) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl StdError for Error { | ||||
|     fn source(&self) -> Option<&(dyn StdError + 'static)> { | ||||
|         self.inner | ||||
|             .cause | ||||
|   | ||||
| @@ -371,15 +371,11 @@ struct IncompleteBody; | ||||
|  | ||||
| impl fmt::Display for IncompleteBody { | ||||
|     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||||
|         f.write_str(self.description()) | ||||
|         write!(f, "end of file before message length reached") | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl StdError for IncompleteBody { | ||||
|     fn description(&self) -> &str { | ||||
|         "end of file before message length reached" | ||||
|     } | ||||
| } | ||||
| impl StdError for IncompleteBody {} | ||||
|  | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|   | ||||
| @@ -205,15 +205,11 @@ impl Pending { | ||||
|  | ||||
| impl fmt::Display for UpgradeExpected { | ||||
|     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||||
|         f.write_str(self.description()) | ||||
|         write!(f, "upgrade expected but not completed") | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl StdError for UpgradeExpected { | ||||
|     fn description(&self) -> &str { | ||||
|         "upgrade expected but not completed" | ||||
|     } | ||||
| } | ||||
| impl StdError for UpgradeExpected {} | ||||
|  | ||||
| // ===== impl Io ===== | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user