当前位置: 首页>>代码示例>>Java>>正文


Java OnErrorFailedException类代码示例

本文整理汇总了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);
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:CallArbiter.java

示例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);
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:BodyOnSubscribe.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ResultOnSubscribe.java

示例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));
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:BodyOnSubscribe.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:ResultOnSubscribe.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:AsyncTest.java

示例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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:CallArbiter.java

示例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));
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:CallArbiter.java

示例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());
    }
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:32,代码来源:SafeObserverTest.java


注:本文中的rx.exceptions.OnErrorFailedException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。