pub fn decode_error(errno: i32) -> IoError {
    // FIXME: this should probably be a bit more descriptive...
    let (kind, desc) = match errno {
        libc::EOF => (old_io::EndOfFile, "end of file"),
        libc::ECONNREFUSED => (old_io::ConnectionRefused, "connection refused"),
        libc::ECONNRESET => (old_io::ConnectionReset, "connection reset"),
        libc::EPERM | libc::EACCES =>
            (old_io::PermissionDenied, "permission denied"),
        libc::EPIPE => (old_io::BrokenPipe, "broken pipe"),
        libc::ENOTCONN => (old_io::NotConnected, "not connected"),
        libc::ECONNABORTED => (old_io::ConnectionAborted, "connection aborted"),
        libc::EADDRNOTAVAIL => (old_io::ConnectionRefused, "address not available"),
        libc::EADDRINUSE => (old_io::ConnectionRefused, "address in use"),
        libc::ENOENT => (old_io::FileNotFound, "no such file or directory"),
        libc::EISDIR => (old_io::InvalidInput, "illegal operation on a directory"),
        libc::ENOSYS => (old_io::IoUnavailable, "function not implemented"),
        libc::EINVAL => (old_io::InvalidInput, "invalid argument"),
        libc::ENOTTY =>
            (old_io::MismatchedFileTypeForOperation,
             "file descriptor is not a TTY"),
        libc::ETIMEDOUT => (old_io::TimedOut, "operation timed out"),
        libc::ECANCELED => (old_io::TimedOut, "operation aborted"),
        libc::consts::os::posix88::EEXIST =>
            (old_io::PathAlreadyExists, "path already exists"),

        // These two constants can have the same value on some systems,
        // but different values on others, so we can't use a match
        // clause
        x if x == libc::EAGAIN || x == libc::EWOULDBLOCK =>
            (old_io::ResourceUnavailable, "resource temporarily unavailable"),

        _ => (old_io::OtherIoError, "unknown error")
    };
    IoError { kind: kind, desc: desc, detail: None }
}
/// Convert an `errno` value into a high-level error variant and description.
Convert an `errno` value into a high-level error variant and description.
Convert an ` errno ` value into a high - level error variant and description .
pub fn decode_error(errno: i32) -> IoError {
    // FIXME: this should probably be a bit more descriptive...
    let (kind, desc) = match errno {
        libc::EOF => (old_io::EndOfFile, "end of file"),
        libc::ECONNREFUSED => (old_io::ConnectionRefused, "connection refused"),
        libc::ECONNRESET => (old_io::ConnectionReset, "connection reset"),
        libc::EPERM | libc::EACCES =>
            (old_io::PermissionDenied, "permission denied"),
        libc::EPIPE => (old_io::BrokenPipe, "broken pipe"),
        libc::ENOTCONN => (old_io::NotConnected, "not connected"),
        libc::ECONNABORTED => (old_io::ConnectionAborted, "connection aborted"),
        libc::EADDRNOTAVAIL => (old_io::ConnectionRefused, "address not available"),
        libc::EADDRINUSE => (old_io::ConnectionRefused, "address in use"),
        libc::ENOENT => (old_io::FileNotFound, "no such file or directory"),
        libc::EISDIR => (old_io::InvalidInput, "illegal operation on a directory"),
        libc::ENOSYS => (old_io::IoUnavailable, "function not implemented"),
        libc::EINVAL => (old_io::InvalidInput, "invalid argument"),
        libc::ENOTTY =>
            (old_io::MismatchedFileTypeForOperation,
             "file descriptor is not a TTY"),
        libc::ETIMEDOUT => (old_io::TimedOut, "operation timed out"),
        libc::ECANCELED => (old_io::TimedOut, "operation aborted"),
        libc::consts::os::posix88::EEXIST =>
            (old_io::PathAlreadyExists, "path already exists"),
        // These two constants can have the same value on some systems,
        // but different values on others, so we can't use a match
        // clause
        x if x == libc::EAGAIN || x == libc::EWOULDBLOCK =>
            (old_io::ResourceUnavailable, "resource temporarily unavailable"),
        _ => (old_io::OtherIoError, "unknown error")
    };
    IoError { kind: kind, desc: desc, detail: None }
}
pub fn decode_error ( errno : i32 ) -> IoError { // FIXME: this should probably be a bit more descriptive... let ( kind , desc ) = match errno { libc :: EOF => ( old_io :: EndOfFile , " " ) , libc :: ECONNREFUSED => ( old_io :: ConnectionRefused , " " ) , libc :: ECONNRESET => ( old_io :: ConnectionReset , " " ) , libc :: EPERM | libc :: EACCES => ( old_io :: PermissionDenied , " " ) , libc :: EPIPE => ( old_io :: BrokenPipe , " " ) , libc :: ENOTCONN => ( old_io :: NotConnected , " " ) , libc :: ECONNABORTED => ( old_io :: ConnectionAborted , " " ) , libc :: EADDRNOTAVAIL => ( old_io :: ConnectionRefused , " " ) , libc :: EADDRINUSE => ( old_io :: ConnectionRefused , " " ) , libc :: ENOENT => ( old_io :: FileNotFound , " " ) , libc :: EISDIR => ( old_io :: InvalidInput , " " ) , libc :: ENOSYS => ( old_io :: IoUnavailable , " " ) , libc :: EINVAL => ( old_io :: InvalidInput , " " ) , libc :: ENOTTY => ( old_io :: MismatchedFileTypeForOperation , " " ) , libc :: ETIMEDOUT => ( old_io :: TimedOut , " " ) , libc :: ECANCELED => ( old_io :: TimedOut , " " ) , libc :: consts :: os :: posix88 :: EEXIST => ( old_io :: PathAlreadyExists , " " ) , // These two constants can have the same value on some systems, // but different values on others, so we can't use a match // clause x if x == libc :: EAGAIN || x == libc :: EWOULDBLOCK => ( old_io :: ResourceUnavailable , " " ) , _ => ( old_io :: OtherIoError , " " ) } ; IoError { kind : kind , desc : desc , detail : None } }
Convert an `errno` value into a high-level error variant and description.
Convert an ` errno ` value into a high - level error variant and description .
errno
i32
errno
i32