I am using NSURLSession to request http post to server. It works fine if everything is ok. But I can't get the response when the server throw an exception. In browser, I should be able to get the 505 error code. But I can't get it in swift. Below is the code I used. Is there anything wrong with it?
let task = NSURLSession.sharedSession().dataTaskWithRequest(request, completionHandler: {
(data, response, error) in
//this method is not called
print("get response from register service \(data) \(error)")
})
task.resume()