android - Retrofit 2.0 OnFailure - Raw Response -
i'm using retrofit
call web service , retrofit throwing failure, the message 'throwable` giving me
java.lang.illegalstateexception: expected begin_object string @ line 1 column 1 path $
i'm assuming because .net web service throwing error , not returning json. prove need able see raw response in onfailure
. there anyway can this?
this code i'm using
public void userloginrequestevent(final authenticateuserevent event) { call call = sapi.login(event.getusername(), event.getpassword(), os_type, deviceinfoutils.getdevicename()); call.enqueue(new callback<loggedinuser>() { @override public void onresponse(response<loggedinuser> response, retrofit retrofit) { // response.issuccess() true if response code 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 } } @override public void onfailure(throwable t) { // handle execution failures no internet connectivity log.d("error", t.getmessage()); } });
you can use log interceptor exists in okhttp-logging-interceptor.
a example can found in logging retrofit 2 well.
Comments
Post a Comment