Skip to content

Instantly share code, notes, and snippets.

@CassiusPacheco
Created August 18, 2017 06:47
Show Gist options
  • Select an option

  • Save CassiusPacheco/9ce6e7a2ff63e5d23c06e21c02fa1d9b to your computer and use it in GitHub Desktop.

Select an option

Save CassiusPacheco/9ce6e7a2ff63e5d23c06e21c02fa1d9b to your computer and use it in GitHub Desktop.
CFURL errors
enum NetworkFailureCode: Int {
case unknown = -1
case cancelled = -999
case badURL = -1000
case timedOut = -1001
case unsupportedURL = -1002
case cannotFindHost = -1003
case cannotConnectToHost = -1004
case dataLengthExceedsMaximum = -1103
case networkConnectionLost = -1005
case dnsLookupFailed = -1006
case httpTooManyRedirects = -1007
case resourceUnavailable = -1008
case notConnectedToInternet = -1009
case redirectToNonExistentLocation = -1010
case badServerResponse = -1011
case userCancelledAuthentication = -1012
case userAuthenticationRequired = -1013
case zeroByteResource = -1014
case cannotDecodeRawData = -1015
case cannotDecodeContentData = -1016
case cannotParseResponse = -1017
case internationalRoamingOff = -1018
case callIsActive = -1019
case dataNotAllowed = -1020
case requestBodyStreamExhausted = -1021
case fileDoesNotExist = -1100
case fileIsDirectory = -1101
case noPermissionsToReadFile = -1102
case secureConnectionFailed = -1200
case serverCertificateHasBadDate = -1201
case serverCertificateUntrusted = -1202
case serverCertificateHasUnknownRoot = -1203
case serverCertificateNotYetValid = -1204
case clientCertificateRejected = -1205
case clientCertificateRequired = -1206
case cannotLoadFromNetwork = -2000
case cannotCreateFile = -3000
case cannotOpenFile = -3001
case cannotCloseFile = -3002
case cannotWriteToFile = -3003
case cannotRemoveFile = -3004
case cannotMoveFile = -3005
case downloadDecodingFailedMidStream = -3006
case downloadDecodingFailedToComplete = -3007
}
extension NSError {
var networkFailureCode: NetworkFailureCode? {
return NetworkFailureCode(rawValue: self.code)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment