NSError from HTTP status code
Foundation objects for making network requests will often return these NSError
for you. NSURLConnection
for example will provide NSError
in completionHandler
its method +sendAsynchronousRequest:queue:completionHandler:
.
If you want to rollback yourself, you can instantiate it NSError
, set it as error domain like NSURLErrorDomain
, set it code
as the HTTP status code you want, and set it localizedDescription
to be user-readable.
source to share