These are chat archives for ReactiveX/RxJava

Jul 2016
Eugene Popovich
Jul 25 2016 07:19
Hello everybody. Does anybody know whether it is possible to use retry logic without the exception itself? For example retrofit returns response with error (isError() true)? Or i should rethrow wrapped exception?
Eugene Popovich
Jul 25 2016 08:14
Had to implement the following workaround
public static <T> Observable.Transformer<Result<T>, Result<T>> retryOnError(int maxRetryCount) {
        return observable -> observable
                .flatMap(response -> response.isError() ? Observable.error(response.error()) : Observable.just(response))
                .retry((count, throwable) -> {
                            Timber.e(throwable, "retryOnError");
                            Timber.d("retryOnError: count=%d; maxRetryCount=%d", count, maxRetryCount);
                            if (count > maxRetryCount) {
                                Timber.d("retryOnError: don't retry, max retry count reached");
                                return false;
                            } else {
                                Timber.d("retryOnError: retry");
                                return true;
                .onErrorResumeNext(t -> Observable.just(Result.error(t)));