我在android中使用改型来执行api。
示例代码段
Call<UniversalPojo> call = apiInterface.storeData(AppClass.getInstance().getLoggedInUser().getRemember_token(), requestBody);
call.enqueue(new Callback<UniversalPojo>() {
@Override
public void onResponse(Call<UniversalPojo> call, Response<UniversalPojo> response) {
if (response.isSuccessful()) {
} else {
//I want to read code at this stage in string.
}
}
@Override
public void onFailure(Call<UniversalPojo> call, Throwable t) {
t.printStackTrace();
}
});
我这里的问题是如何获得if(response.issusccessful())的else块的字符串错误。
1条答案
按热度按时间rqmkfv5c1#
使用
OkHttpClient
班级addInterceptor(interceptor: Interceptor)
功能覆盖
intercept(chain: Interceptor.Chain)
函数并按预期引发异常: