AFNetworking和网络错误 [英] AFNetworking and Network Errors

查看:199
本文介绍了AFNetworking和网络错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AFNetworking 框架来发出多个JSON网页请求。

I am using the AFNetworking framework to make several JSON web request.

在开发过程中如果我未能提供所需的参数或服务开发人员破坏了一些东西:-)我收到 500错误

During development if I fail to provide a required parameters or the Service developers have broken something :-) i receive a 500 error

错误块 AFJSONRequestOperation 正确捕获它。但是我无法看到页面正文,因为 AfNetworking 在收到头部错误代码后立即取消请求。

The Error block of AFJSONRequestOperation is correctly catching it. However i cannot see the page body because AfNetworking is cancelling the request as soon as the error code in the head is received.

是否有一些解决方法。我想将响应主体吐出到日志中。

Is there some work around. I would like to spit out the response body to the log.

推荐答案

您需要将http代码500添加到日志中。可接受的状态代码并在成功回调中对其进行过滤。在那里你将有一个responseObject。

You'll need to add the http Code 500 to the acceptable status codes and filter it on the success callback. There you will have a responseObject.

这篇关于AFNetworking和网络错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆