src/main/java/io/reactivex/internal/util/HalfSerializer.java
public static void onError(Observer<?> observer, Throwable ex,
            AtomicInteger wip, AtomicThrowable error) {
        if (error.addThrowable(ex)) {
            if (wip.getAndIncrement() == 0) {
                observer.onError(error.terminate());
            }
        } else {
            RxJavaPlugins.onError(ex);
        }
    }
public static void onError(Observer<?> observer, Throwable ex,
            AtomicInteger wip, AtomicThrowable error) {
        if (error.addThrowable(ex)) {
            if (wip.getAndIncrement() == 0) {
                observer.onError(error.terminate());
            }
        } else {
            RxJavaPlugins.onError(ex);
        }
    }
Emits the given exception if possible or adds it to the given error container to
be emitted by a concurrent onNext if one is running.
Undeliverable exceptions are sent to the RxJavaPlugins.onError.
@param observer the target Subscriber to emit to
@param ex the Throwable to emit
@param wip the serialization work-in-progress counter/indicator
@param error the holder of Throwables