title: How do I make RxJava call onErrorReturn() and still execute onError()
body: <p>When I call the Retrofit method <code>GetTodoRepository.fetchTodo()</code> from <code>MainViewModel</code> and call ends in a failure or any non-success result, I would like to let RxJava to both do <code>onErrorReturn()</code> and <code>onError()</code> so I can return a cached object in that case, but still notify <code>MainViewModel</code> that an error happend, so I can show error-related UI views. How do I archive this?</p>
  
  <p>The current code shows how I intended to handle it. </p>
  
  <p><strong>MainViewModel</strong> </p>
  
  <pre><code>public class MainViewModel extends ViewModel
  
      public LiveData&lt;String&gt; getTodo() {
      getTodoRepository.fetchTodo().subscribe(new SingleObserver&lt;String&gt;() {
          @Override
          public void onSubscribe(Disposable d) {
          }
  
          @Override
          public void onSuccess(String s) {
              showProgressAnim.setValue(false);
              todo.setValue(s);
          }
  
          @Override
          public void onError(Throwable e) {
              showProgressAnim.setValue(false);
              errorMsg.setValue(e.getMessage());
          }
       });
          return todo;
      }
  }
  </code></pre>
  
  <p><strong>GetTodoRepository</strong></p>
  
  <pre><code>public class GetTodoRepository {
  
      public Single&lt;String&gt; fetchTodo() {
          return retrofit.create(TodoApi.class)
              .getTodo()
              .doOnSuccess(s -&gt; cacheManager.saveTodo(s))
              .onErrorReturn(throwable -&gt; cacheManager.getTodo())
              .subscribeOn(Schedulers.io())
              .observeOn(AndroidSchedulers.mainThread());
      }
  }
  </code></pre>