Skip to content

Make POSIXError use POSIXErrorCode from Swift Stdlib #933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 12 additions & 110 deletions Foundation/NSError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
//
//===----------------------------------------------------------------------===//

#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux) || os(Android)
import Glibc
#endif

import CoreFoundation

Expand Down Expand Up @@ -865,6 +870,9 @@ public extension URLError {

/// Describes an error in the POSIX error domain.
public struct POSIXError : _BridgedStoredNSError {

public typealias Code = POSIXErrorCode

public let _nsError: NSError

public init(_nsError error: NSError) {
Expand All @@ -873,117 +881,11 @@ public struct POSIXError : _BridgedStoredNSError {
}

public static var _nsErrorDomain: String { return NSPOSIXErrorDomain }
}

public enum Code : Int, _ErrorCodeProtocol {
public typealias _ErrorType = POSIXError

case EPERM
case ENOENT
case ESRCH
case EINTR
case EIO
case ENXIO
case E2BIG
case ENOEXEC
case EBADF
case ECHILD
case EDEADLK
case ENOMEM
case EACCES
case EFAULT
case ENOTBLK
case EBUSY
case EEXIST
case EXDEV
case ENODEV
case ENOTDIR
case EISDIR
case EINVAL
case ENFILE
case EMFILE
case ENOTTY
case ETXTBSY
case EFBIG
case ENOSPC
case ESPIPE
case EROFS
case EMLINK
case EPIPE
case EDOM
case ERANGE
case EAGAIN
case EWOULDBLOCK
case EINPROGRESS
case EALREADY
case ENOTSOCK
case EDESTADDRREQ
case EMSGSIZE
case EPROTOTYPE
case ENOPROTOOPT
case EPROTONOSUPPORT
case ESOCKTNOSUPPORT
case ENOTSUP
case EPFNOSUPPORT
case EAFNOSUPPORT
case EADDRINUSE
case EADDRNOTAVAIL
case ENETDOWN
case ENETUNREACH
case ENETRESET
case ECONNABORTED
case ECONNRESET
case ENOBUFS
case EISCONN
case ENOTCONN
case ESHUTDOWN
case ETOOMANYREFS
case ETIMEDOUT
case ECONNREFUSED
case ELOOP
case ENAMETOOLONG
case EHOSTDOWN
case EHOSTUNREACH
case ENOTEMPTY
case EPROCLIM
case EUSERS
case EDQUOT
case ESTALE
case EREMOTE
case EBADRPC
case ERPCMISMATCH
case EPROGUNAVAIL
case EPROGMISMATCH
case EPROCUNAVAIL
case ENOLCK
case ENOSYS
case EFTYPE
case EAUTH
case ENEEDAUTH
case EPWROFF
case EDEVERR
case EOVERFLOW
case EBADEXEC
case EBADARCH
case ESHLIBVERS
case EBADMACHO
case ECANCELED
case EIDRM
case ENOMSG
case EILSEQ
case ENOATTR
case EBADMSG
case EMULTIHOP
case ENODATA
case ENOLINK
case ENOSR
case ENOSTR
case EPROTO
case ETIME
case ENOPOLICY
case ENOTRECOVERABLE
case EOWNERDEAD
case EQFULL
}
extension POSIXErrorCode: _ErrorCodeProtocol {

public typealias _ErrorType = POSIXError
}

extension POSIXError {
Expand Down