android - Handling error in RoboSpice -


i'm new in robospice , i'm having problem in handling error request. there way can access response body error request in onrequestfailure method? if not, how guys it?

private class requestlistener implements requestlistener<object> {     @override     public void onrequestfailure(spiceexception e) {      }      @override     public void onrequestsuccess(object response) {      } } 

there's suggestion should error checking inside spice request. suggestion guys?

@override public subscriptionscontainer loaddatafromnetwork() {     responseentity<subscriptionscontainer> response = null;     try {           response = getresttemplate().exchange(/*your request data*/);     } catch (httpclienterrorexception e) {        string responsebody =  e.getresponsebodyasstring();     } } 

if throw exception loaddatafromnetwork(), wrapped spiceexception , passed onrequestfailure() argument.

therefore, should check responseentity<t> conditions expect , throw exception in case not fulfilled. if, on hand, resttemplate.exchange call throws exception, handle (as in example) or let thrown (so reported onrequestfailure() on main thread).


Comments