Skip to content

Commit

Permalink
std: improve io error descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Dec 10, 2015
1 parent dc37e9f commit 025f97a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/libstd/io/error.rs
Expand Up @@ -311,9 +311,31 @@ impl fmt::Display for Error {

#[stable(feature = "rust1", since = "1.0.0")]
impl error::Error for Error {
#[allow(deprecated)] // remove with UnexpectedEOF
fn description(&self) -> &str {
match self.repr {
Repr::Os(..) => "os error",
Repr::Os(..) => match self.kind() {
ErrorKind::NotFound => "entity not found",
ErrorKind::PermissionDenied => "permission denied",
ErrorKind::ConnectionRefused => "connection refused",
ErrorKind::ConnectionReset => "connection reset",
ErrorKind::ConnectionAborted => "connection aborted",
ErrorKind::NotConnected => "not connected",
ErrorKind::AddrInUse => "address in use",
ErrorKind::AddrNotAvailable => "address not available",
ErrorKind::BrokenPipe => "broken pipe",
ErrorKind::AlreadyExists => "entity already exists",
ErrorKind::WouldBlock => "operation would block",
ErrorKind::InvalidInput => "invalid input parameter",
ErrorKind::InvalidData => "invalid data",
ErrorKind::TimedOut => "timed out",
ErrorKind::WriteZero => "write zero",
ErrorKind::Interrupted => "operation interrupted",
ErrorKind::Other => "other os error",
ErrorKind::UnexpectedEOF => "unexpected end of file",
ErrorKind::UnexpectedEof => "unexpected end of file",
ErrorKind::__Nonexhaustive => unreachable!()
},
Repr::Custom(ref c) => c.error.description(),
}
}
Expand Down

0 comments on commit 025f97a

Please sign in to comment.