gpt4 book ai didi

retrofit - 在新的 Retrofit 2 API 中使用什么来代替 RetrofitError.Kind.NETWORK?

转载 作者:行者123 更新时间:2023-12-04 15:32:58 26 4
gpt4 key购买 nike

在 Retrofit 1.9.x 中有一个 RetrofitError.Kind.NETWORK这让您可以轻松确定故障是否由网络错误引起。在新的 2.0 API 中,我们不再有 RetrofitError是否有一个简单的等价物我们可以用来测试 Response由于网络失败?

最佳答案

查看Retrofit 1.9.0版本的源码,貌似只有一次RetrofitErrorKind.NETWORK创建是如果有 IOException尝试调用请求时。在使用新的 2.0 API 时,我们应该能够自己进行相同的检查。

关于retrofit - 在新的 Retrofit 2 API 中使用什么来代替 RetrofitError.Kind.NETWORK?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32442370/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com