Skip to content

Instantly share code, notes, and snippets.

@kebbbnnn
Created November 16, 2017 05:10
Show Gist options
  • Save kebbbnnn/cc98f79fad45956c06bb85c56c87e3fc to your computer and use it in GitHub Desktop.
Save kebbbnnn/cc98f79fad45956c06bb85c56c87e3fc to your computer and use it in GitHub Desktop.
.retryWhen(errors -> errors.flatMap(error -> {
// For IOExceptions, we retry
if (error instanceof RetrofitError) {
RetrofitError retrofitError = (RetrofitError) error;
Response response = retrofitError.getResponse();
if (response.getStatus() == 504) {
return Observable.just(null);
}
}
// For anything else, don't retry
return Observable.error(error);
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment