【发布时间】:2016-04-07 15:53:26
【问题描述】:
所以出于某种原因,我需要像这样执行我的调用:
val result = manager.call.execute()
if (result.isSuccess) {
//do stuff
} else {
//handle exeption
}
当我的代码到达else 括号时,result.body() 为 null,result.errorBody() 的缓冲区内容为 0,但长度不为 0。
但是,这是我从改造中得到的日志:
<-- 400 Bad Request https://cubus-friends-
...
D/OkHttp: {"error":"validation_error","error_description":"No user with that phone number"}
D/OkHttp: <-- END HTTP (81-byte body)
如何将我的 json 错误字符串放入代码中的 else 括号中?
【问题讨论】:
-
你试过这个吗:Getting JSON from RetrofitError? P.S:看看 Retrofit 2.0 部分
-
好的,所以我没有注意到评论末尾的 Retrofit 2 部分...谢谢!