Adopting Swift Error Constants
Migrate existing C code to Swift, using the error constants provided by the System module.
Overview
The C error constants map to Swift as follows:
E2BIG⟶ argListTooLongEACCES⟶ permissionDeniedEADDRINUSE⟶ addressInUseEADDRNOTAVAIL⟶ addressNotAvailableEAFNOSUPPORT⟶ addressFamilyNotSupportedEAGAIN⟶ resourceTemporarilyUnavailableEALREADY⟶ alreadyInProcessEAUTH⟶ authenticationErrorEBADARCH⟶ badCPUTypeEBADEXEC⟶ badExecutableEBADF⟶ badFileDescriptorEBADMACHO⟶ malformedMachOEBADMSG⟶ badMessageEBADRPC⟶ rpcUnsuccessfulEBUSY⟶ resourceBusyECANCELED⟶ canceledECHILD⟶ noChildProcessECONNABORTED⟶ connectionAbortECONNREFUSED⟶ connectionRefusedECONNRESET⟶ connectionResetEDEADLK⟶ deadlockEDESTADDRREQ⟶ addressRequiredEDEVERR⟶ deviceErrorEDOM⟶ outOfDomainEDQUOT⟶ diskQuotaExceededEEXIST⟶ fileExistsEFAULT⟶ badAddressEFBIG⟶ fileTooLargeEFTYPE⟶ badFileTypeOrFormatEHOSTDOWN⟶ hostIsDownEHOSTUNREACH⟶ noRouteToHostEIDRM⟶ identifierRemovedEILSEQ⟶ illegalByteSequenceEINPROGRESS⟶ nowInProgressEINTR⟶ interruptedEINVAL⟶ invalidArgumentEIO⟶ ioErrorEISCONN⟶ socketIsConnectedEISDIR⟶ isDirectoryELAST⟶ lastErrnoValueELOOP⟶ tooManySymbolicLinkLevelsEMFILE⟶ tooManyOpenFilesEMLINK⟶ tooManyLinksEMSGSIZE⟶ messageTooLongEMULTIHOP⟶ multiHopENAMETOOLONG⟶ fileNameTooLongENEEDAUTH⟶ needAuthenticatorENETDOWN⟶ networkDownENETRESET⟶ networkResetENETUNREACH⟶ networkUnreachableENFILE⟶ tooManyOpenFilesInSystemENOATTR⟶ attributeNotFoundENOBUFS⟶ noBufferSpaceENODATA⟶ noDataENODEV⟶ operationNotSupportedByDeviceENOENT⟶ noSuchFileOrDirectoryENOEXEC⟶ execFormatErrorENOLCK⟶ noLocksENOLINK⟶ noLinkENOMEM⟶ noMemoryENOMSG⟶ noMessageENOPOLICY⟶ noSuchPolicyENOPROTOOPT⟶ protocolNotAvailableENOSPC⟶ noSpaceENOSR⟶ noStreamResourcesENOSTR⟶ notStreamENOSYS⟶ noFunctionENOTBLK⟶ notBlockDeviceENOTCONN⟶ socketNotConnectedENOTDIR⟶ notDirectoryENOTEMPTY⟶ directoryNotEmptyENOTRECOVERABLE⟶ notRecoverableENOTSOCK⟶ notSocketENOTSUP⟶ notSupportedENOTTY⟶ inappropriateIOCTLForDeviceENXIO⟶ noSuchAddressOrDeviceEOPNOTSUPP⟶ notSupportedOnSocketEOVERFLOW⟶ overflowEOWNERDEAD⟶ previousOwnerDiedEPERM⟶ notPermittedEPFNOSUPPORT⟶ protocolFamilyNotSupportedEPIPE⟶ brokenPipeEPROCLIM⟶ tooManyProcessesEPROCUNAVAIL⟶ rpcProcedureUnavailableEPROGMISMATCH⟶ rpcProgramVersionMismatchEPROGUNAVAIL⟶ rpcProgramUnavailableEPROTONOSUPPORT⟶ protocolNotSupportedEPROTOTYPE⟶ protocolWrongTypeForSocketEPROTO⟶ protocolErrorEPWROFF⟶ devicePowerIsOffEQFULL⟶ outputQueueFullERANGE⟶ outOfRangeEREMOTE⟶ tooManyRemoteLevelsEROFS⟶ readOnlyFileSystemERPCMISMATCH⟶ rpcVersionMismatchESHLIBVERS⟶ sharedLibraryVersionMismatchESHUTDOWN⟶ socketShutdownESOCKTNOSUPPORT⟶ socketTypeNotSupportedESPIPE⟶ illegalSeekESRCH⟶ noSuchProcessESTALE⟶ staleNFSFileHandleETIMEDOUT⟶ timedOutETIME⟶ timeoutETOOMANYREFS⟶ tooManyReferencesETXTBSY⟶ textFileBusyEUSERS⟶ tooManyUsersEWOULDBLOCK⟶ wouldBlockEXDEV⟶ improperLink