Skip to content

Commit f0ed9f9

Browse files
committed
Auto merge of #30312 - seanmonstar:ioerror-description, r=alexcrichton
cc @pnkfelix @alexcrichton
2 parents e583ab6 + 025f97a commit f0ed9f9

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/libstd/io/error.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,31 @@ impl fmt::Display for Error {
311311

312312
#[stable(feature = "rust1", since = "1.0.0")]
313313
impl error::Error for Error {
314+
#[allow(deprecated)] // remove with UnexpectedEOF
314315
fn description(&self) -> &str {
315316
match self.repr {
316-
Repr::Os(..) => "os error",
317+
Repr::Os(..) => match self.kind() {
318+
ErrorKind::NotFound => "entity not found",
319+
ErrorKind::PermissionDenied => "permission denied",
320+
ErrorKind::ConnectionRefused => "connection refused",
321+
ErrorKind::ConnectionReset => "connection reset",
322+
ErrorKind::ConnectionAborted => "connection aborted",
323+
ErrorKind::NotConnected => "not connected",
324+
ErrorKind::AddrInUse => "address in use",
325+
ErrorKind::AddrNotAvailable => "address not available",
326+
ErrorKind::BrokenPipe => "broken pipe",
327+
ErrorKind::AlreadyExists => "entity already exists",
328+
ErrorKind::WouldBlock => "operation would block",
329+
ErrorKind::InvalidInput => "invalid input parameter",
330+
ErrorKind::InvalidData => "invalid data",
331+
ErrorKind::TimedOut => "timed out",
332+
ErrorKind::WriteZero => "write zero",
333+
ErrorKind::Interrupted => "operation interrupted",
334+
ErrorKind::Other => "other os error",
335+
ErrorKind::UnexpectedEOF => "unexpected end of file",
336+
ErrorKind::UnexpectedEof => "unexpected end of file",
337+
ErrorKind::__Nonexhaustive => unreachable!()
338+
},
317339
Repr::Custom(ref c) => c.error.description(),
318340
}
319341
}

0 commit comments

Comments
 (0)