how to handle RxAndroid errors in the main thread
<p>I'm new to rxJava/Android and surprised that my <code>onError</code> lambda is  sometimes called on the main-thread and sometimes not, although I use <code>.observeOn(AndroidSchedulers.mainThread())</code></p>

<p><em>Example 1</em>: <code>onError</code> on main-thread<br>
this works as expected: <code>onError</code> is called on the main-thread</p>

<pre class="lang-java prettyprint-override"><code>Observable.error(new RuntimeException("RTE"))
    .subscribeOn(Schedulers.newThread())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(s -&gt; {
                Log.e(TAG, "onNext("+s+")-thread: " + Thread.currentThread().getName());
            },
            throwable -&gt; {
                Log.e(TAG, "onError()-thread: " + Thread.currentThread().getName());
            });
</code></pre>

<p>log-output:</p>

<pre><code>onError()-thread: main
</code></pre>

<p><em>Example 2</em>: <code>onError</code> <strong>NOT</strong> on main-thread</p>

<pre class="lang-java prettyprint-override"><code>Observable.create(new Observable.OnSubscribe&lt;String&gt;() {
    @Override
    public void call(Subscriber&lt;? super String&gt; subscriber) {
        subscriber.onNext("one and only");
    }
})
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.timeout(1, TimeUnit.SECONDS)
.subscribe(s -&gt; {
        Log.e(TAG, "onNext("+s+")-thread: " + Thread.currentThread().getName());
    },
    throwable -&gt; {
        Log.e(TAG, "onError()-thread: " + Thread.currentThread().getName());
    });
</code></pre>

<p>the output is something like this:</p>

<pre><code>onNext(one and only)-thread: main
onError()-thread: RxComputationScheduler-4       
</code></pre>

<p>I thought that after calling <a href="http://reactivex.io/RxJava/javadoc/rx/Observable.html#observeOn(rx.Schedul" rel="noreferrer">observeOn(AndroidSchedulers.mainThread())</a>, ALL emissions should be done on the main-thread.</p>

<p>so I have these questions:</p>

<ol>
<li>I could not find any documentation that specifies under what circumstances <code>onError</code> is called in which thread. Anyone knows a link?</li>
<li>I do of course want to display some error-indication in the GUI: so how can I force <code>onError</code> to be ALWAYS called in the main-thread?</li>
</ol>