Browse Source

Stop using Error::description method

which is now deprecated in stable Rust.
Johannes Hofmann 5 years ago
parent
commit
3e1524056f
1 changed files with 26 additions and 3 deletions
  1. 26
    3
      src/error.rs

+ 26
- 3
src/error.rs View File

105
 impl StdError for Error {
105
 impl StdError for Error {
106
     fn description(&self) -> &str {
106
     fn description(&self) -> &str {
107
         match *self.0 {
107
         match *self.0 {
108
-            ErrorKind::Io(ref err) => err.description(),
109
-            ErrorKind::Protobuf { ref err, .. } => err.description(),
110
-            ErrorKind::StringtableUtf8 { ref err, .. } => err.description(),
108
+            ErrorKind::Io(ref err, ..) => {
109
+                use std::io::ErrorKind;
110
+                match err.kind() {
111
+                    ErrorKind::NotFound => "io error: not found",
112
+                    ErrorKind::PermissionDenied => "io error: permission denied",
113
+                    ErrorKind::ConnectionRefused => "io error: connection refused",
114
+                    ErrorKind::ConnectionReset => "io error: connection reset",
115
+                    ErrorKind::ConnectionAborted => "io error: connection aborted",
116
+                    ErrorKind::NotConnected => "io error: not connected",
117
+                    ErrorKind::AddrInUse => "io error: address in use",
118
+                    ErrorKind::AddrNotAvailable => "io error: address not available",
119
+                    ErrorKind::BrokenPipe => "io error: broken pipe",
120
+                    ErrorKind::AlreadyExists => "io error: already exists",
121
+                    ErrorKind::WouldBlock => "io error: would block",
122
+                    ErrorKind::InvalidInput => "io error: invalid input",
123
+                    ErrorKind::InvalidData => "io error: invalid data",
124
+                    ErrorKind::TimedOut => "io error: timed out",
125
+                    ErrorKind::WriteZero => "io error: write zero",
126
+                    ErrorKind::Interrupted => "io error: interrupted",
127
+                    ErrorKind::Other => "io error: other",
128
+                    ErrorKind::UnexpectedEof => "io error: unexpected EOF",
129
+                    _ => "io error",
130
+                }
131
+            }
132
+            ErrorKind::Protobuf { .. } => "protobuf error",
133
+            ErrorKind::StringtableUtf8 { .. } => "UTF-8 error in stringtable",
111
             ErrorKind::StringtableIndexOutOfBounds { .. } => "stringtable index out of bounds",
134
             ErrorKind::StringtableIndexOutOfBounds { .. } => "stringtable index out of bounds",
112
             ErrorKind::Blob(BlobError::InvalidHeaderSize) => {
135
             ErrorKind::Blob(BlobError::InvalidHeaderSize) => {
113
                 "blob header size could not be decoded"
136
                 "blob header size could not be decoded"