Skip to content

Commit e0651e2

Browse files
committed
1 parent f5475a0 commit e0651e2

File tree

1 file changed

+293
-0
lines changed

1 file changed

+293
-0
lines changed

Foundation/NSError.swift

Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,299 @@ extension POSIXErrorCode: _ErrorCodeProtocol {
915915
public typealias _ErrorType = POSIXError
916916
}
917917

918+
#if os(Linux) || os(Android)
919+
920+
/// Enumeration describing POSIX error codes.
921+
// See https://bugs.swift.org/browse/SR-10485
922+
public enum POSIXErrorCode: Int32 {
923+
924+
/// Operation not permitted.
925+
case EPERM = 1
926+
/// No such file or directory.
927+
case ENOENT = 2
928+
/// No such process.
929+
case ESRCH = 3
930+
/// Interrupted system call.
931+
case EINTR = 4
932+
/// Input/output error.
933+
case EIO = 5
934+
/// Device not configured.
935+
case ENXIO = 6
936+
/// Argument list too long.
937+
case E2BIG = 7
938+
/// Exec format error.
939+
case ENOEXEC = 8
940+
/// Bad file descriptor.
941+
case EBADF = 9
942+
/// No child processes.
943+
case ECHILD = 10
944+
/// Try again.
945+
case EAGAIN = 11
946+
/// Cannot allocate memory.
947+
case ENOMEM = 12
948+
/// Permission denied.
949+
case EACCES = 13
950+
/// Bad address.
951+
case EFAULT = 14
952+
/// Block device required.
953+
case ENOTBLK = 15
954+
/// Device / Resource busy.
955+
case EBUSY = 16
956+
/// File exists.
957+
case EEXIST = 17
958+
/// Cross-device link.
959+
case EXDEV = 18
960+
/// Operation not supported by device.
961+
case ENODEV = 19
962+
/// Not a directory.
963+
case ENOTDIR = 20
964+
/// Is a directory.
965+
case EISDIR = 21
966+
/// Invalid argument.
967+
case EINVAL = 22
968+
/// Too many open files in system.
969+
case ENFILE = 23
970+
/// Too many open files.
971+
case EMFILE = 24
972+
/// Inappropriate ioctl for device.
973+
case ENOTTY = 25
974+
/// Text file busy.
975+
case ETXTBSY = 26
976+
/// File too large.
977+
case EFBIG = 27
978+
/// No space left on device.
979+
case ENOSPC = 28
980+
/// Illegal seek.
981+
case ESPIPE = 29
982+
/// Read-only file system.
983+
case EROFS = 30
984+
/// Too many links.
985+
case EMLINK = 31
986+
/// Broken pipe.
987+
case EPIPE = 32
988+
989+
/// Numerical argument out of domain.
990+
case EDOM = 33
991+
/// Result too large.
992+
case ERANGE = 34
993+
994+
/// Resource deadlock would occur.
995+
case EDEADLK = 35
996+
997+
/// File name too long.
998+
case ENAMETOOLONG = 36
999+
1000+
/// No record locks available
1001+
case ENOLCK = 37
1002+
1003+
/// Function not implemented.
1004+
case ENOSYS = 38
1005+
1006+
/// Directory not empty.
1007+
case ENOTEMPTY = 39
1008+
1009+
/// Too many symbolic links encountered
1010+
case ELOOP = 40
1011+
1012+
/// Operation would block.
1013+
public static var EWOULDBLOCK: POSIXErrorCode { return .EAGAIN }
1014+
1015+
/// No message of desired type.
1016+
case ENOMSG = 42
1017+
1018+
/// Identifier removed.
1019+
case EIDRM = 43
1020+
1021+
/// Channel number out of range.
1022+
case ECHRNG = 44
1023+
1024+
/// Level 2 not synchronized.
1025+
case EL2NSYNC = 45
1026+
1027+
/// Level 3 halted
1028+
case EL3HLT = 46
1029+
1030+
/// Level 3 reset.
1031+
case EL3RST = 47
1032+
1033+
/// Link number out of range.
1034+
case ELNRNG = 48
1035+
1036+
/// Protocol driver not attached.
1037+
case EUNATCH = 49
1038+
1039+
/// No CSI structure available.
1040+
case ENOCSI = 50
1041+
1042+
/// Level 2 halted.
1043+
case EL2HLT = 51
1044+
/// Invalid exchange
1045+
case EBADE = 52
1046+
/// Invalid request descriptor
1047+
case EBADR = 53
1048+
/// Exchange full
1049+
case EXFULL = 54
1050+
/// No anode
1051+
case ENOANO = 55
1052+
/// Invalid request code
1053+
case EBADRQC = 56
1054+
/// Invalid slot
1055+
case EBADSLT = 57
1056+
1057+
public static var EDEADLOCK: POSIXErrorCode { return .EDEADLK }
1058+
1059+
/// Bad font file format
1060+
case EBFONT = 59
1061+
/// Device not a stream
1062+
case ENOSTR = 60
1063+
/// No data available
1064+
case ENODATA = 61
1065+
/// Timer expired
1066+
case ETIME = 62
1067+
/// Out of streams resources
1068+
case ENOSR = 63
1069+
/// Machine is not on the network
1070+
case ENONET = 64
1071+
/// Package not installed
1072+
case ENOPKG = 65
1073+
/// Object is remote
1074+
case EREMOTE = 66
1075+
/// Link has been severed
1076+
case ENOLINK = 67
1077+
/// Advertise error
1078+
case EADV = 68
1079+
/// Srmount error
1080+
case ESRMNT = 69
1081+
/// Communication error on send
1082+
case ECOMM = 70
1083+
/// Protocol error
1084+
case EPROTO = 71
1085+
/// Multihop attempted
1086+
case EMULTIHOP = 72
1087+
/// RFS specific error
1088+
case EDOTDOT = 73
1089+
/// Not a data message
1090+
case EBADMSG = 74
1091+
/// Value too large for defined data type
1092+
case EOVERFLOW = 75
1093+
/// Name not unique on network
1094+
case ENOTUNIQ = 76
1095+
/// File descriptor in bad state
1096+
case EBADFD = 77
1097+
/// Remote address changed
1098+
case EREMCHG = 78
1099+
/// Can not access a needed shared library
1100+
case ELIBACC = 79
1101+
/// Accessing a corrupted shared library
1102+
case ELIBBAD = 80
1103+
/// .lib section in a.out corrupted
1104+
case ELIBSCN = 81
1105+
/// Attempting to link in too many shared libraries
1106+
case ELIBMAX = 82
1107+
/// Cannot exec a shared library directly
1108+
case ELIBEXEC = 83
1109+
/// Illegal byte sequence
1110+
case EILSEQ = 84
1111+
/// Interrupted system call should be restarted
1112+
case ERESTART = 85
1113+
/// Streams pipe error
1114+
case ESTRPIPE = 86
1115+
/// Too many users
1116+
case EUSERS = 87
1117+
/// Socket operation on non-socket
1118+
case ENOTSOCK = 88
1119+
/// Destination address required
1120+
case EDESTADDRREQ = 89
1121+
/// Message too long
1122+
case EMSGSIZE = 90
1123+
/// Protocol wrong type for socket
1124+
case EPROTOTYPE = 91
1125+
/// Protocol not available
1126+
case ENOPROTOOPT = 92
1127+
/// Protocol not supported
1128+
case EPROTONOSUPPORT = 93
1129+
/// Socket type not supported
1130+
case ESOCKTNOSUPPORT = 94
1131+
/// Operation not supported on transport endpoint
1132+
case EOPNOTSUPP = 95
1133+
/// Protocol family not supported
1134+
case EPFNOSUPPORT = 96
1135+
/// Address family not supported by protocol
1136+
case EAFNOSUPPORT = 97
1137+
/// Address already in use
1138+
case EADDRINUSE = 98
1139+
/// Cannot assign requested address
1140+
case EADDRNOTAVAIL = 99
1141+
/// Network is down
1142+
case ENETDOWN = 100
1143+
/// Network is unreachable
1144+
case ENETUNREACH = 101
1145+
/// Network dropped connection because of reset
1146+
case ENETRESET = 102
1147+
/// Software caused connection abort
1148+
case ECONNABORTED = 103
1149+
/// Connection reset by peer
1150+
case ECONNRESET = 104
1151+
/// No buffer space available
1152+
case ENOBUFS = 105
1153+
/// Transport endpoint is already connected
1154+
case EISCONN = 106
1155+
/// Transport endpoint is not connected
1156+
case ENOTCONN = 107
1157+
/// Cannot send after transport endpoint shutdown
1158+
case ESHUTDOWN = 108
1159+
/// Too many references: cannot splice
1160+
case ETOOMANYREFS = 109
1161+
/// Connection timed out
1162+
case ETIMEDOUT = 110
1163+
/// Connection refused
1164+
case ECONNREFUSED = 111
1165+
/// Host is down
1166+
case EHOSTDOWN = 112
1167+
/// No route to host
1168+
case EHOSTUNREACH = 113
1169+
/// Operation already in progress
1170+
case EALREADY = 114
1171+
/// Operation now in progress
1172+
case EINPROGRESS = 115
1173+
/// Stale NFS file handle
1174+
case ESTALE = 116
1175+
/// Structure needs cleaning
1176+
case EUCLEAN = 117
1177+
/// Not a XENIX named type file
1178+
case ENOTNAM = 118
1179+
/// No XENIX semaphores available
1180+
case ENAVAIL = 119
1181+
/// Is a named type file
1182+
case EISNAM = 120
1183+
/// Remote I/O error
1184+
case EREMOTEIO = 121
1185+
/// Quota exceeded
1186+
case EDQUOT = 122
1187+
1188+
/// No medium found
1189+
case ENOMEDIUM = 123
1190+
/// Wrong medium type
1191+
case EMEDIUMTYPE = 124
1192+
/// Operation Canceled
1193+
case ECANCELED = 125
1194+
/// Required key not available
1195+
case ENOKEY = 126
1196+
/// Key has expired
1197+
case EKEYEXPIRED = 127
1198+
/// Key has been revoked
1199+
case EKEYREVOKED = 128
1200+
/// Key was rejected by service
1201+
case EKEYREJECTED = 129
1202+
1203+
/// Owner died
1204+
case EOWNERDEAD = 130
1205+
/// State not recoverable
1206+
case ENOTRECOVERABLE = 131
1207+
}
1208+
1209+
#endif
1210+
9181211
extension POSIXError {
9191212
/// Operation not permitted.
9201213
public static var EPERM: POSIXError.Code { return .EPERM }

0 commit comments

Comments
 (0)