本文整理汇总了Java中rx.exceptions.OnErrorFailedException类的典型用法代码示例。如果您正苦于以下问题:Java OnErrorFailedException类的具体用法?Java OnErrorFailedException怎么用?Java OnErrorFailedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OnErrorFailedException类属于rx.exceptions包,在下文中一共展示了OnErrorFailedException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: emitError
import rx.exceptions.OnErrorFailedException; //导入依赖的package包/类
void emitError(Throwable t) {
set(STATE_TERMINATED);
if (!isUnsubscribed()) {
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);
}
}
}
示例2: onNext
import rx.exceptions.OnErrorFailedException; //导入依赖的package包/类
@Override public void onNext(Response<R> response) {
if (response.isSuccessful()) {
subscriber.onNext(response.body());
} else {
subscriberTerminated = true;
Throwable t = new HttpException(response);
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);
}
}
}
示例3: onError
import rx.exceptions.OnErrorFailedException; //导入依赖的package包/类
@Override public void onError(Throwable throwable) {
try {
subscriber.onNext(Result.<R>error(throwable));
} catch (Throwable 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;
}
subscriber.onCompleted();
}
示例4: onNext
import rx.exceptions.OnErrorFailedException; //导入依赖的package包/类
@Override
public void onNext(Response<R> response) {
if (response.isSuccessful()) {
subscriber.onNext(response.body());
} else {
subscriberTerminated = true;
Throwable t = new HttpException(response);
try {
subscriber.onError(t);
} catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
RxJavaHooks.getOnError().call(e);
} catch (Throwable inner) {
Exceptions.throwIfFatal(inner);
RxJavaHooks.getOnError().call(new CompositeException(t, inner));
}
}
}
示例5: onError
import rx.exceptions.OnErrorFailedException; //导入依赖的package包/类
@Override
public void onError(Throwable throwable) {
try {
subscriber.onNext(Result.<R>error(throwable));
} catch (Throwable t) {
try {
subscriber.onError(t);
} catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
RxJavaHooks.getOnError().call(e);
} catch (Throwable inner) {
Exceptions.throwIfFatal(inner);
RxJavaHooks.getOnError().call(new CompositeException(t, inner));
}
return;
}
subscriber.onCompleted();
}
示例6: bodyThrowingInOnSafeSubscriberErrorDeliveredToPlugin
import rx.exceptions.OnErrorFailedException; //导入依赖的package包/类
@Test public void bodyThrowingInOnSafeSubscriberErrorDeliveredToPlugin()
throws InterruptedException {
server.enqueue(new MockResponse().setResponseCode(404));
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
@Override public void handleError(Throwable throwable) {
if (throwable instanceof OnErrorFailedException) {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
latch.countDown();
}
}
});
final TestSubscriber<Void> subscriber = new TestSubscriber<>();
final RuntimeException e = new RuntimeException();
final AtomicReference<Throwable> errorRef = new AtomicReference<>();
service.completable().subscribe(new AsyncCompletableSubscriber() {
@Override public void onCompleted() {
subscriber.onCompleted();
}
@Override public void onError(Throwable t) {
errorRef.set(t);
throw e;
}
});
assertTrue(latch.await(1, SECONDS));
OnErrorFailedException failed = (OnErrorFailedException) pluginRef.get();
CompositeException composite = (CompositeException) failed.getCause();
assertThat(composite.getExceptions()).containsExactly(errorRef.get(), e);
}
示例7: emitComplete
import rx.exceptions.OnErrorFailedException; //导入依赖的package包/类
void emitComplete() {
set(STATE_TERMINATED);
try {
if (!isUnsubscribed()) {
subscriber.onCompleted();
}
} catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
RxJavaHooks.getOnError().call(e);
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
RxJavaHooks.getOnError().call(t);
}
}
示例8: emitError
import rx.exceptions.OnErrorFailedException; //导入依赖的package包/类
void emitError(Throwable t) {
set(STATE_TERMINATED);
if (!isUnsubscribed()) {
try {
subscriber.onError(t);
} catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
RxJavaHooks.getOnError().call(e);
} catch (Throwable inner) {
Exceptions.throwIfFatal(inner);
RxJavaHooks.getOnError().call(new CompositeException(t, inner));
}
}
}
示例9: onErrorSuccessWithUnsubscribeFailure
import rx.exceptions.OnErrorFailedException; //导入依赖的package包/类
@Test
public void onErrorSuccessWithUnsubscribeFailure() {
AtomicReference<Throwable> onError = new AtomicReference<Throwable>();
Subscriber<String> o = OBSERVER_SUCCESS(onError);
try {
o.add(Subscriptions.create(new Action0() {
@Override
public void call() {
// break contract by throwing exception
throw new SafeObserverTestException("failure from unsubscribe");
}
}));
new SafeSubscriber<String>(o).onError(new SafeObserverTestException("failed"));
fail("we expect the unsubscribe failure to cause an exception to be thrown");
} catch (Exception e) {
e.printStackTrace();
assertTrue(o.isUnsubscribed());
// we still expect onError to have received something before unsubscribe blew up
assertNotNull(onError.get());
assertTrue(onError.get() instanceof SafeObserverTestException);
assertEquals("failed", onError.get().getMessage());
// now assert the exception that was thrown
OnErrorFailedException onErrorFailedException = (OnErrorFailedException) e;
assertTrue(onErrorFailedException.getCause() instanceof SafeObserverTestException);
assertEquals("failure from unsubscribe", e.getMessage());
}
}