From 025f97a1def6c5fc2169931c18ee818ba5479f84 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 10 Dec 2015 13:29:33 -0800 Subject: [PATCH] std: improve io error descriptions --- src/libstd/io/error.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs index 1ff8f572a7f57..1dd96f5ddfc01 100644 --- a/src/libstd/io/error.rs +++ b/src/libstd/io/error.rs @@ -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(), } }