android retrofit 2.0,android – Retrofit 2.0 OnFailure – 原始响应

我正在使用改造来调用Web服务并且改造失败,来自’Throwable`的消息给了我

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

我假设这是因为.Net Web服务抛出错误而不返回JSON.但为了证明这一点,我需要能够在onFailure中看到原始响应.无论如何我能做到吗?

这是我正在使用的代码

public void userLoginRequestEvent(final AuthenticateUserEvent event) {

Call call = sApi.login(event.getUsername(),event.getPassword(),OS_TYPE,DeviceInfoUtils.getDeviceName());

call.enqueue(new Callback() {

@Override

public void onResponse(Response response,Retrofit retrofit) {

// response.isSuccess() is true if the response code is 2xx

if (response.isSuccess()) {

LoggedInUser user = response.body();

AppBus.getInstance()

.post(new UserIsAuthenticatedEvent(user,event.getUsername(),event.getPassword()));

} else {

int statusCode = response.code();

// handle request errors yourself

}

}

@Override

public void onFailure(Throwable t) {

// handle execution failures like no internet connectivity

Log.d("ERROR",t.getMessage());

}

});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值