Search in sources :

Example 6 with OnCompletedFailedException

use of rx.exceptions.OnCompletedFailedException in project retrofit by square.

the class CallArbiter method deliverResponse.

private void deliverResponse(Response<T> response) {
    try {
        if (!isUnsubscribed()) {
            subscriber.onNext(response);
        }
    } catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
        RxJavaPlugins.getInstance().getErrorHandler().handleError(e);
        return;
    } catch (Throwable t) {
        Exceptions.throwIfFatal(t);
        try {
            subscriber.onError(t);
        } catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
            RxJavaPlugins.getInstance().getErrorHandler().handleError(e);
        } catch (Throwable inner) {
            Exceptions.throwIfFatal(inner);
            CompositeException composite = new CompositeException(t, inner);
            RxJavaPlugins.getInstance().getErrorHandler().handleError(composite);
        }
        return;
    }
    try {
        if (!isUnsubscribed()) {
            subscriber.onCompleted();
        }
    } catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
        RxJavaPlugins.getInstance().getErrorHandler().handleError(e);
    } catch (Throwable t) {
        Exceptions.throwIfFatal(t);
        RxJavaPlugins.getInstance().getErrorHandler().handleError(t);
    }
}
Also used : OnCompletedFailedException(rx.exceptions.OnCompletedFailedException) CompositeException(rx.exceptions.CompositeException) OnErrorNotImplementedException(rx.exceptions.OnErrorNotImplementedException) OnErrorFailedException(rx.exceptions.OnErrorFailedException)

Aggregations

OnCompletedFailedException (rx.exceptions.OnCompletedFailedException)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 MockResponse (okhttp3.mockwebserver.MockResponse)4 Test (org.junit.Test)4 RxJavaErrorHandler (rx.plugins.RxJavaErrorHandler)4 CompositeException (rx.exceptions.CompositeException)2 OnErrorFailedException (rx.exceptions.OnErrorFailedException)2 OnErrorNotImplementedException (rx.exceptions.OnErrorNotImplementedException)2 Response (com.lzy.okgo.model.Response)1 Response (retrofit2.Response)1