Procházet zdrojové kódy

Stop using Error::description method

which is now deprecated in stable Rust.
Johannes Hofmann před 5 roky
rodič
revize
3e1524056f
1 změnil soubory, kde provedl 26 přidání a 3 odebrání
  1. 26
    3
      src/error.rs

+ 26
- 3
src/error.rs Zobrazit soubor

@@ -105,9 +105,32 @@ impl From<Error> for io::Error {
105 105
 impl StdError for Error {
106 106
     fn description(&self) -> &str {
107 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 134
             ErrorKind::StringtableIndexOutOfBounds { .. } => "stringtable index out of bounds",
112 135
             ErrorKind::Blob(BlobError::InvalidHeaderSize) => {
113 136
                 "blob header size could not be decoded"