赞
踩
NSURLErrorDomain
& CFNetworkErrors
The greatest source of failure in iOS apps is networking. Between radios, transport, data roaming policies, proxies, security, authentication, and any number of protocol-specific negotiation, there is a lot that can go wrong.
On the plus side, the Foundation URL Loading system is incredibly mature, and takes care of most of that for you. The only negative is that the documentation for all of the various things that can go wrong is scattered across different programming guides and headers. If you get a request failing with error -1004
, it can be surprisingly difficult to figure out exactly what that means.
As such, here is an exhaustive, well-formatted table at your disposal:
Code | Description |
---|---|
-1NSURLErrorUnknown | |
1kCFHostErrorHostNotFound | Indicates that the DNS lookup failed. |
2kCFHostErrorUnknown | An unknown error occurred (a name server failure, for example). For additional information, query the kCFGetAddrInfoFailureKey to get the value returned from getaddrinfo; lookup in netdb.h |
100kCFSOCKSErrorUnknownClientVersion | The SOCKS server rejected access because it does not support connections with the requested SOCKS version.Query kCFSOCKSStatusCodeKey to recover the status code returned by the server. |
101kCFSOCKSErrorUnsupportedServerVersion | The version of SOCKS requested by the server is not supported. Query kCFSOCKSStatusCodeKey to recover the status code returned by the server. |
110kCFSOCKS4ErrorRequestFailed | Request rejected or failed by the server. |
111kCFSOCKS4ErrorIdentdFailed | Request rejected because SOCKS server cannot connect to identd on the client. |
112kCFSOCKS4ErrorIdConflict | Request rejected because the client program and identd report different user-ids. |
113kCFSOCKS4ErrorUnknownStatusCode | The status code returned by the server is unknown. |
120kCFSOCKS5ErrorBadState | The stream is not in a state that allows the requested operation. |
121kCFSOCKS5ErrorBadResponseAddr | The address type returned is not supported. |
122kCFSOCKS5ErrorBadCredentials | The SOCKS server refused the client connection because of bad login credentials. |
123kCFSOCKS5ErrorUnsupportedNegotiationMethod | The requested method is not supported. Query kCFSOCKSNegotiationMethodKey to find the method requested. |
124kCFSOCKS5ErrorNoAcceptableMethod | The client and server could not find a mutually agreeable authentication method. |
200kCFFTPErrorUnexpectedStatusCode | The server returned an unexpected status code. Query the kCFFTPStatusCodeKey to get the status code returned by the server |
300kCFErrorHTTPAuthenticationTypeUnsupported | The client and server could not agree on a supported authentication type. |
301kCFErrorHTTPBadCredentials | The credentials provided for an authenticated connection were rejected by the server. |
302kCFErrorHTTPConnectionLost | The connection to the server was dropped. This usually indicates a highly overloaded server. |
303kCFErrorHTTPParseFailure | The HTTP server response could not be parsed. |
304kCFErrorHTTPRedirectionLoopDetected | Too many HTTP redirects occurred before reaching a page that did not redirect the client to another page. This usually indicates a redirect loop. |
305kCFErrorHTTPBadURL | The requested URL could not be retrieved. |
306kCFErrorHTTPProxyConnectionFailure | A connection could not be established to the HTTP proxy. |
307kCFErrorHTTPBadProxyCredentials | The authentication credentials provided for logging into the proxy were rejected. |
308kCFErrorPACFileError | An error occurred with the proxy autoconfiguration file. |
309kCFErrorPACFileAuth | The authentication credentials provided by the proxy autoconfiguration file were rejected. |
310kCFErrorHTTPSProxyConnectionFailure | A connection could not be established to the HTTPS proxy. |
311kCFStreamErrorHTTPSProxyFailureUnexpectedResponseToCONNECTMethod | The HTTPS proxy returned an unexpected status code, such as a 3xx redirect. |
-998kCFURLErrorUnknown | An unknown error occurred. |
-999kCFURLErrorCancelled NSURLErrorCancelled | The connection was cancelled. |
-1000kCFURLErrorBadURL NSURLErrorBadURL | The connection failed due to a malformed URL. |
-1001kCFURLErrorTimedOut NSURLErrorTimedOut | The connection timed out. |
-1002kCFURLErrorUnsupportedURL NSURLErrorUnsupportedURL | The connection failed due to an unsupported URL scheme. |
-1003kCFURLErrorCannotFindHost NSURLErrorCannotFindHost | The connection failed because the host could not be found. |
-1004kCFURLErrorCannotConnectToHost NSURLErrorCannotConnectToHost | The connection failed because a connection cannot be made to the host. |
-1005kCFURLErrorNetworkConnectionLost NSURLErrorNetworkConnectionLost | The connection failed because the network connection was lost. |
-1006kCFURLErrorDNSLookupFailed NSURLErrorDNSLookupFailed | The connection failed because the DNS lookup failed. |
-1007kCFURLErrorHTTPTooManyRedirects NSURLErrorHTTPTooManyRedirects | The HTTP connection failed due to too many redirects. |
-1008kCFURLErrorResourceUnavailable NSURLErrorResourceUnavailable | The connection’s resource is unavailable. |
-1009kCFURLErrorNotConnectedToInternet NSURLErrorNotConnectedToInternet | The connection failed because the device is not connected to the internet. |
-1010kCFURLErrorRedirectToNonExistentLocation NSURLErrorRedirectToNonExistentLocation | The connection was redirected to a nonexistent location. |
-1011kCFURLErrorBadServerResponse NSURLErrorBadServerResponse | The connection received an invalid server response. |
-1012kCFURLErrorUserCancelledAuthentication NSURLErrorUserCancelledAuthentication | The connection failed because the user cancelled required authentication. |
-1013kCFURLErrorUserAuthenticationRequired NSURLErrorUserAuthenticationRequired | The connection failed because authentication is required. |
-1014kCFURLErrorZeroByteResource NSURLErrorZeroByteResource | The resource retrieved by the connection is zero bytes. |
-1015kCFURLErrorCannotDecodeRawData NSURLErrorCannotDecodeRawData | The connection cannot decode data encoded with a known content encoding. |
-1016kCFURLErrorCannotDecodeContentData NSURLErrorCannotDecodeContentData | The connection cannot decode data encoded with an unknown content encoding. |
-1017kCFURLErrorCannotParseResponse NSURLErrorCannotParseResponse | The connection cannot parse the server’s response. |
-1018kCFURLErrorInternationalRoamingOff | The connection failed because international roaming is disabled on the device. |
-1019kCFURLErrorCallIsActive | The connection failed because a call is active. |
-1020kCFURLErrorDataNotAllowed | The connection failed because data use is currently not allowed on the device. |
-1021kCFURLErrorRequestBodyStreamExhausted | The connection failed because its request’s body stream was exhausted. |
-1100kCFURLErrorFileDoesNotExist NSURLErrorFileDoesNotExist | The file operation failed because the file does not exist. |
-1101kCFURLErrorFileIsDirectory NSURLErrorFileIsDirectory | The file operation failed because the file is a directory. |
-1102kCFURLErrorNoPermissionsToReadFile NSURLErrorNoPermissionsToReadFile | The file operation failed because it does not have permission to read the file. |
-1103kCFURLErrorDataLengthExceedsMaximum NSURLErrorDataLengthExceedsMaximum | The file operation failed because the file is too large. |
-1200kCFURLErrorSecureConnectionFailed NSURLErrorSecureConnectionFailed | The secure connection failed for an unknown reason. |
-1201kCFURLErrorServerCertificateHasBadDate NSURLErrorServerCertificateHasBadDate | The secure connection failed because the server’s certificate has an invalid date. |
-1202kCFURLErrorServerCertificateUntrusted NSURLErrorServerCertificateUntrusted | The secure connection failed because the server’s certificate is not trusted. |
-1203kCFURLErrorServerCertificateHasUnknownRoot NSURLErrorServerCertificateHasUnknownRoot | The secure connection failed because the server’s certificate has an unknown root. |
-1204kCFURLErrorServerCertificateNotYetValid NSURLErrorServerCertificateNotYetValid | The secure connection failed because the server’s certificate is not yet valid. |
-1205kCFURLErrorClientCertificateRejected NSURLErrorClientCertificateRejected | The secure connection failed because the client’s certificate was rejected. |
-1206kCFURLErrorClientCertificateRequired NSURLErrorClientCertificateRequired | The secure connection failed because the server requires a client certificate. |
-2000kCFURLErrorCannotLoadFromNetwork NSURLErrorCannotLoadFromNetwork | The connection failed because it is being required to return a cached resource, but one is not available. |
-3000kCFURLErrorCannotCreateFile NSURLErrorCannotCreateFile | The file cannot be created. |
-3001kCFURLErrorCannotOpenFile NSURLErrorCannotOpenFile | The file cannot be opened. |
-3002kCFURLErrorCannotCloseFile NSURLErrorCannotCloseFile | The file cannot be closed. |
-3003kCFURLErrorCannotWriteToFile NSURLErrorCannotWriteToFile | The file cannot be written. |
-3004kCFURLErrorCannotRemoveFile NSURLErrorCannotRemoveFile | The file cannot be removed. |
-3005kCFURLErrorCannotMoveFile NSURLErrorCannotMoveFile | The file cannot be moved. |
-3006kCFURLErrorDownloadDecodingFailedMidStream NSURLErrorDownloadDecodingFailedMidStream | The download failed because decoding of the downloaded data failed mid-stream. |
-3007kCFURLErrorDownloadDecodingFailedToComplete NSURLErrorDownloadDecodingFailedToComplete | The download failed because decoding of the downloaded data failed to complete. |
-4000kCFHTTPCookieCannotParseCookieFile | The cookie file cannot be parsed. |
-72000LkCFNetServiceErrorUnknown | An unknown error occurred. |
-72001LkCFNetServiceErrorCollision | An attempt was made to use a name that is already in use. |
-72002LkCFNetServiceErrorNotFound | Not used. |
-72003LkCFNetServiceErrorInProgress | A new search could not be started because a search is already in progress. |
-72004LkCFNetServiceErrorBadArgument | A required argument was not provided or was not valid. |
-72005LkCFNetServiceErrorCancel | The search or service was cancelled. |
-72006LkCFNetServiceErrorInvalid | Invalid data was passed to a CFNetServices function. |
-72007LkCFNetServiceErrorTimeout | A search failed because it timed out. |
-73000LkCFNetServiceErrorDNSServiceFailure | An error from DNS discovery; look at kCFDNSServiceFailureKey to get the error number and interpret using dnssd.h |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。