@@ -64,8 +64,24 @@ pub fn unsupported_err() -> Error {
6464 Error :: new ( ErrorKind :: Other , "operation not supported on wasm yet" )
6565}
6666
67- pub fn decode_error_kind ( _code : i32 ) -> ErrorKind {
68- ErrorKind :: Other
67+ pub fn decode_error_kind ( errno : i32 ) -> ErrorKind {
68+ match errno as libc:: c_int {
69+ libc:: ECONNREFUSED => ErrorKind :: ConnectionRefused ,
70+ libc:: ECONNRESET => ErrorKind :: ConnectionReset ,
71+ libc:: EPERM | libc:: EACCES => ErrorKind :: PermissionDenied ,
72+ libc:: EPIPE => ErrorKind :: BrokenPipe ,
73+ libc:: ENOTCONN => ErrorKind :: NotConnected ,
74+ libc:: ECONNABORTED => ErrorKind :: ConnectionAborted ,
75+ libc:: EADDRNOTAVAIL => ErrorKind :: AddrNotAvailable ,
76+ libc:: EADDRINUSE => ErrorKind :: AddrInUse ,
77+ libc:: ENOENT => ErrorKind :: NotFound ,
78+ libc:: EINTR => ErrorKind :: Interrupted ,
79+ libc:: EINVAL => ErrorKind :: InvalidInput ,
80+ libc:: ETIMEDOUT => ErrorKind :: TimedOut ,
81+ libc:: EEXIST => ErrorKind :: AlreadyExists ,
82+ libc:: EAGAIN => ErrorKind :: WouldBlock ,
83+ _ => ErrorKind :: Other ,
84+ }
6985}
7086
7187// This enum is used as the storage for a bunch of types which can't actually
0 commit comments