I've already added onErrorReturn and doOnError, but I still get fatal error. Here's my code:
apiInterface.submitDataToAnalyze("dataToAnalyze", HelperFunctions.authenticationData, 1, uuid, dataToAnalyze.toString(), todayDate)
.onErrorReturn(new Func1<Throwable, BasicResponse>() {
@Override
public BasicResponse call(Throwable throwable) {
Log.e(FILE_NAME, "submitDataToAnalyze throwable??");
Log.e(FILE_NAME, throwable.getMessage().toString());
return null;
}
})
.flatMap(new Func1<BasicResponse, Observable<LocationSuggestion>>() {
@Override
public Observable<LocationSuggestion> call(BasicResponse basicResponse) {
Log.v(FILE_NAME, "basicResponse: " + basicResponse.toString());
if (basicResponse.getResult() == 1) {
//update TABLE_REQUEST_SUGGESTIONS with serverResponse = 1
dbc.updateRequestSuggestionLog(strTodayDate, strDataToAnalyze, basicResponse.getResult());
return apiInterface.getSuggestion("getSuggestion", HelperFunctions.authenticationData, HelperFunctions.requestVersion, uuid,
strLocationLat, strLocationLng, radius, requestForDate);
} else {
return Observable.just(null);
}
}
}).doOnError(new Action1<Throwable>() {
@Override
public void call(Throwable t) {
Log.e(FILE_NAME, "masuk doOnError??");
Log.e(FILE_NAME, t.getMessage().toString());
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe();
}
Specifically, here's the error message:
E/ISRS: masuk doOnError??
E/ISRS: masuk 22??
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.IllegalStateException: Exception thrown on Scheduler.Worker thread. Add `onError` handling.
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:60)
Additional information: the fatal error would occur if submitDataToAnalyze() has problem connecting to my server due to bad connection etc