Java Code Examples for io.reactivex.plugins.RxJavaPlugins#onError()

The following examples show how to use io.reactivex.plugins.RxJavaPlugins#onError() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlowableStateMachine.java    From rxjava2-extras with Apache License 2.0 6 votes vote down vote up
@Override
public void onError(Throwable e) {
    if (done) {
        RxJavaPlugins.onError(e);
        return;
    }
    done = true;
    if (!createdState()) {
        return;
    }
    if (errorAction != null) {
        try {
            errorAction.accept(state, e, this);
        } catch (Throwable err) {
            Exceptions.throwIfFatal(e);
            onError_(err);
            return;
        }
    } else {
        onError_(e);
    }
}
 
Example 2
Source File: SerializedConnectionListener.java    From rxjava2-jdbc with Apache License 2.0 6 votes vote down vote up
private void drain() {
    if (getAndIncrement() == 0) {
        int missed = 1;
        while (true) {
            Optional<Throwable> o;
            while ((o = queue.poll()) != null) {
                try {
                    c.accept(o);
                } catch (Exception e) {
                    RxJavaPlugins.onError(e);
                }
            }
            missed = addAndGet(-missed);
            if (missed == 0) {
                return;
            }
        }
    }
}
 
Example 3
Source File: WriteStreamSubscriberImpl.java    From vertx-rx with Apache License 2.0 6 votes vote down vote up
private void writeStreamEnd(AsyncResult<Void> result) {
  try {
    Action a;
    if (result.succeeded()) {
      synchronized (this) {
        a = writeStreamEndHandler;
      }
      if (a != null) {
        a.run();
      }
    } else {
      Consumer<? super Throwable> c;
      synchronized (this) {
        c = this.writeStreamEndErrorHandler;
      }
      if (c != null) {
        c.accept(result.cause());
      }
    }
  } catch (Throwable t) {
    Exceptions.throwIfFatal(t);
    RxJavaPlugins.onError(t);
  }
}
 
Example 4
Source File: MemberSingle.java    From rxjava2-jdbc with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    if (!cancelled) {
        try {
            log.debug("creating value");
            // this action might block so is scheduled
            T value = pool.factory.call();
            m.setValueAndClearReleasingFlag(value);
            checkin(m, true);
        } catch (Throwable t) {
            RxJavaPlugins.onError(t);
            // check cancelled again because factory.call() is user specified and could have
            // taken a significant time to complete
            if (!cancelled) {
                // schedule a retry
                scheduled.add(scheduler.scheduleDirect(this, createRetryIntervalMs, TimeUnit.MILLISECONDS));
            }
        }
    }
}
 
Example 5
Source File: QueryToOptionalOperator.java    From sqlbrite with Apache License 2.0 5 votes vote down vote up
@Override public void onError(Throwable e) {
  if (isDisposed()) {
    RxJavaPlugins.onError(e);
  } else {
    downstream.onError(e);
  }
}
 
Example 6
Source File: MemberSingle.java    From rxjava2-jdbc with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    worker.dispose();
    try {
        observer.child.onSuccess(m);
    } catch (Throwable e) {
        RxJavaPlugins.onError(e);
    } finally {
        observer.dispose();
    }
}
 
Example 7
Source File: BodyObservable.java    From retrocache with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable throwable) {
    if (!mTerminated) {
        mObserver.onError(throwable);
    } else {
        // This should never happen! onNext handles and forwards errors automatically.
        Throwable broken = new AssertionError(
                "This should never happen! Report as a bug with the full stacktrace.");
        //noinspection UnnecessaryInitCause Two-arg AssertionError constructor is 1.7+ only.
        broken.initCause(throwable);
        RxJavaPlugins.onError(broken);
    }
}
 
Example 8
Source File: TraceContextSubscriber.java    From brave with Apache License 2.0 5 votes vote down vote up
@Override public void onError(Throwable t) {
  if (done) {
    RxJavaPlugins.onError(t);
    return;
  }
  done = true;

  Scope scope = contextScoper.maybeScope(assembled);
  try { // retrolambda can't resolve this try/finally
    downstream.onError(t);
  } finally {
    scope.close();
  }
}
 
Example 9
Source File: CallEnqueueObservable.java    From okhttp-OkGo with Apache License 2.0 5 votes vote down vote up
@Override
public void onSuccess(Response<T> response) {
    if (call.isCanceled()) return;

    try {
        observer.onNext(response);
    } catch (Exception e) {
        if (terminated) {
            RxJavaPlugins.onError(e);
        } else {
            onError(response);
        }
    }
}
 
Example 10
Source File: BodyObservable.java    From okhttp-OkGo with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(Response<R> response) {
    if (response.isSuccessful()) {
        observer.onNext(response.body());
    } else {
        terminated = true;
        Throwable t = new HttpException(response);
        try {
            observer.onError(t);
        } catch (Throwable inner) {
            Exceptions.throwIfFatal(inner);
            RxJavaPlugins.onError(new CompositeException(t, inner));
        }
    }
}
 
Example 11
Source File: OperatorRunSingleItemQuery.java    From sqlitemagic with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable e) {
  if (isDisposed()) {
    RxJavaPlugins.onError(e);
  } else {
    downstream.onError(e);
  }
}
 
Example 12
Source File: LifeSingleObserver.java    From rxjava-RxLife with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable t) {
    if (isDisposed()) {
        RxJavaPlugins.onError(t);
        return;
    }
    lazySet(DisposableHelper.DISPOSED);
    try {
        removeObserver();
        downstream.onError(t);
    } catch (Throwable e) {
        Exceptions.throwIfFatal(e);
        RxJavaPlugins.onError(new CompositeException(t, e));
    }
}
 
Example 13
Source File: LifeSingleObserver.java    From rxjava-RxLife with Apache License 2.0 5 votes vote down vote up
@Override
public void onSuccess(T t) {
    if (isDisposed()) return;
    lazySet(DisposableHelper.DISPOSED);
    try {
        removeObserver();
        downstream.onSuccess(t);
    } catch (Throwable e) {
        Exceptions.throwIfFatal(e);
        RxJavaPlugins.onError(e);
    }
}
 
Example 14
Source File: ResultObservable.java    From retrocache with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable throwable) {
    try {
        mObserver.onNext(Result.<R>error(throwable));
    } catch (Throwable t) {
        try {
            mObserver.onError(t);
        } catch (Throwable inner) {
            Exceptions.throwIfFatal(inner);
            RxJavaPlugins.onError(new CompositeException(t, inner));
        }
        return;
    }
    mObserver.onComplete();
}
 
Example 15
Source File: FlowableRepeatingTransform.java    From rxjava2-extras with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable t) {
    debug(this + " error " + t);
    if (done) {
        RxJavaPlugins.onError(t);
        return;
    }
    error = t;
    done = true;
    tester.onError(t);
    drain();
}
 
Example 16
Source File: LifeConditionalSubscriber.java    From rxjava-RxLife with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable t) {
    if (isDisposed()) {
        RxJavaPlugins.onError(t);
        return;
    }
    lazySet(SubscriptionHelper.CANCELLED);
    try {
        removeObserver();
        downstream.onError(t);
    } catch (Throwable e) {
        Exceptions.throwIfFatal(e);
        RxJavaPlugins.onError(new CompositeException(t, e));
    }
}
 
Example 17
Source File: FlowableSignalMapper.java    From akarnokd-misc with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable t) {
    if (done) {
        RxJavaPlugins.onError(t);
        return;
    }
    done = true;
    actual.onError(t);
}
 
Example 18
Source File: ResourceFlowableToFlowable.java    From akarnokd-misc with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable t) {
    if (done) {
        RxJavaPlugins.onError(t);
    } else {
        actual.onError(t);
    }
}
 
Example 19
Source File: ResultObservable.java    From okhttp-OkGo with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(Throwable throwable) {
    try {
        observer.onNext(Result.<R>error(throwable));
    } catch (Throwable t) {
        try {
            observer.onError(t);
        } catch (Throwable inner) {
            Exceptions.throwIfFatal(inner);
            RxJavaPlugins.onError(new CompositeException(t, inner));
        }
        return;
    }
    observer.onComplete();
}
 
Example 20
Source File: UncaughtCrash.java    From akarnokd-misc with Apache License 2.0 4 votes vote down vote up
@Test(expected = InternalError.class)
public void test2() {
    RxJavaPlugins.onError(new IOException());
}