根据我们在请求中发送的情绪和信息,我们的服务器可能会发回内容类型为text/plain
的空体204响应或其他类似400系列响应的application/json
身体详细说明错误。我们该如何处理?
我们想到这样的事情:
Alamofire.request(request)
.responseString({ (request, response, string, error) -> Void in
// Happy dance
})
.responseSwiftyJSON({ (request, response, json, error) -> Void in
// Parse the error out of the json response and inform the user
})
...但似乎所有链式响应处理程序都已执行。有没有办法说"只针对特定的错误类型调用这个"或者"只针对特定的响应代码调用此代码"?
我们是否遗漏了有关Alamofire如何运作的信息?