NSError codes: URL Loading system errors that mean loss of network

George Burdell picture George Burdell · Feb 15, 2012 · Viewed 12.1k times · Source

I'm trying to write a definitive list of all possible URL error codes that mean loss of network connection, including blips and extended outage. Here's what I have so far:

NSURLErrorNotConnectedToInternet
NSURLErrorCannotConnectToHost
NSURLErrorTimedOut
NSURLErrorCannotFindHost
NSURLErrorCallIsActive
NSURLErrorNetworkConnectionLost
NSURLErrorDataNotAllowed

I'm reporting web service errors encountered by the app and I want to filter out the errors caused due to no fault of the web service. I look at the URL error code obtained from the error object passed in NSURLConnectionDelegate's connection:didFailWithError: method. Also, I would rather not check for Reachability everytime before calling the web service since the network connection can still be lost at random. If you have your own list or a better suggestion, please let me know. Thanks.

Answer

Nikhil Dinesh picture Nikhil Dinesh · May 17, 2012

NSURLErrorCannotFindHost = -1003,

NSURLErrorCannotConnectToHost = -1004,

NSURLErrorNetworkConnectionLost = -1005,

NSURLErrorDNSLookupFailed = -1006,

NSURLErrorHTTPTooManyRedirects = -1007,

NSURLErrorResourceUnavailable = -1008,

NSURLErrorNotConnectedToInternet = -1009,

NSURLErrorRedirectToNonExistentLocation = -1010,

NSURLErrorInternationalRoamingOff = -1018,

NSURLErrorCallIsActive = -1019,

NSURLErrorDataNotAllowed = -1020,

NSURLErrorSecureConnectionFailed = -1200,

NSURLErrorCannotLoadFromNetwork = -2000,