當前位置: 首頁>>代碼示例>>Java>>正文


Java Exceptions類代碼示例

本文整理匯總了Java中rx.exceptions.Exceptions的典型用法代碼示例。如果您正苦於以下問題:Java Exceptions類的具體用法?Java Exceptions怎麽用?Java Exceptions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Exceptions類屬於rx.exceptions包,在下文中一共展示了Exceptions類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onError

import rx.exceptions.Exceptions; //導入依賴的package包/類
public void onError(Throwable e) {
    Exceptions.throwIfFatal(e);
    if (!this.terminated) {
        synchronized (this) {
            if (this.terminated) {
                return;
            }
            this.terminated = true;
            if (this.emitting) {
                FastList list = this.queue;
                if (list == null) {
                    list = new FastList();
                    this.queue = list;
                }
                list.add(this.nl.error(e));
                return;
            }
            this.emitting = true;
            this.actual.onError(e);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:SerializedObserver.java

示例2: emitError

import rx.exceptions.Exceptions; //導入依賴的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

示例3: onNext

import rx.exceptions.Exceptions; //導入依賴的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

示例4: onError

import rx.exceptions.Exceptions; //導入依賴的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

示例5: throwingInOnCompleteDeliveredToPlugin

import rx.exceptions.Exceptions; //導入依賴的package包/類
@Test public void throwingInOnCompleteDeliveredToPlugin() {
  server.enqueue(new MockResponse());

  final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
  RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
    @Override public void handleError(Throwable throwable) {
      if (!pluginRef.compareAndSet(null, throwable)) {
        throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
      }
    }
  });

  RecordingSubscriber<Void> observer = subscriberRule.create();
  final RuntimeException e = new RuntimeException();
  service.completable().unsafeSubscribe(new ForwardingCompletableObserver(observer) {
    @Override public void onCompleted() {
      throw e;
    }
  });

  assertThat(pluginRef.get()).isSameAs(e);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:CompletableThrowingTest.java

示例6: bodyThrowingInOnCompleteDeliveredToPlugin

import rx.exceptions.Exceptions; //導入依賴的package包/類
@Test public void bodyThrowingInOnCompleteDeliveredToPlugin() {
  server.enqueue(new MockResponse());

  final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
  RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
    @Override public void handleError(Throwable throwable) {
      if (!pluginRef.compareAndSet(null, throwable)) {
        throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
      }
    }
  });

  RecordingSubscriber<String> observer = subscriberRule.create();
  final RuntimeException e = new RuntimeException();
  service.body().unsafeSubscribe(new ForwardingSubscriber<String>(observer) {
    @Override public void onCompleted() {
      throw e;
    }
  });

  observer.assertAnyValue();
  assertThat(pluginRef.get()).isSameAs(e);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:ObservableThrowingTest.java

示例7: responseThrowingInOnCompleteDeliveredToPlugin

import rx.exceptions.Exceptions; //導入依賴的package包/類
@Test public void responseThrowingInOnCompleteDeliveredToPlugin() {
  server.enqueue(new MockResponse());

  final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
  RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
    @Override public void handleError(Throwable throwable) {
      if (!pluginRef.compareAndSet(null, throwable)) {
        throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
      }
    }
  });

  RecordingSubscriber<Response<String>> observer = subscriberRule.create();
  final RuntimeException e = new RuntimeException();
  service.response().unsafeSubscribe(new ForwardingSubscriber<Response<String>>(observer) {
    @Override public void onCompleted() {
      throw e;
    }
  });

  observer.assertAnyValue();
  assertThat(pluginRef.get()).isSameAs(e);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:ObservableThrowingTest.java

示例8: resultThrowingInOnCompletedDeliveredToPlugin

import rx.exceptions.Exceptions; //導入依賴的package包/類
@Test public void resultThrowingInOnCompletedDeliveredToPlugin() {
  server.enqueue(new MockResponse());

  final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
  RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
    @Override public void handleError(Throwable throwable) {
      if (!pluginRef.compareAndSet(null, throwable)) {
        throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
      }
    }
  });

  RecordingSubscriber<Result<String>> observer = subscriberRule.create();
  final RuntimeException e = new RuntimeException();
  service.result().unsafeSubscribe(new ForwardingSubscriber<Result<String>>(observer) {
    @Override public void onCompleted() {
      throw e;
    }
  });

  observer.assertAnyValue();
  assertThat(pluginRef.get()).isSameAs(e);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:ObservableThrowingTest.java

示例9: throwingInOnCompleteDeliveredToPlugin

import rx.exceptions.Exceptions; //導入依賴的package包/類
@Test public void throwingInOnCompleteDeliveredToPlugin() {
  server.enqueue(new MockResponse());

  final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
  RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
    @Override public void handleError(Throwable throwable) {
      if (throwable instanceof OnCompletedFailedException) {
        if (!pluginRef.compareAndSet(null, throwable)) {
          throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
        }
      }
    }
  });

  RecordingSubscriber<Void> observer = subscriberRule.create();
  final RuntimeException e = new RuntimeException();
  service.completable().subscribe(new ForwardingCompletableObserver(observer) {
    @Override public void onCompleted() {
      throw e;
    }
  });

  assertThat(pluginRef.get().getCause()).isSameAs(e);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:CompletableThrowingSafeSubscriberTest.java

示例10: bodyThrowingInOnSuccessDeliveredToPlugin

import rx.exceptions.Exceptions; //導入依賴的package包/類
@Test public void bodyThrowingInOnSuccessDeliveredToPlugin() {
  server.enqueue(new MockResponse());

  final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
  RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
    @Override public void handleError(Throwable throwable) {
      if (!pluginRef.compareAndSet(null, throwable)) {
        throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
      }
    }
  });

  RecordingSubscriber<String> observer = subscriberRule.create();
  final RuntimeException e = new RuntimeException();
  service.body().subscribe(new ForwardingObserver<String>(observer) {
    @Override public void onSuccess(String value) {
      throw e;
    }
  });

  assertThat(pluginRef.get()).isSameAs(e);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:SingleThrowingTest.java

示例11: responseThrowingInOnSuccessDeliveredToPlugin

import rx.exceptions.Exceptions; //導入依賴的package包/類
@Test public void responseThrowingInOnSuccessDeliveredToPlugin() {
  server.enqueue(new MockResponse());

  final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
  RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
    @Override public void handleError(Throwable throwable) {
      if (!pluginRef.compareAndSet(null, throwable)) {
        throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
      }
    }
  });

  RecordingSubscriber<Response<String>> observer = subscriberRule.create();
  final RuntimeException e = new RuntimeException();
  service.response().subscribe(new ForwardingObserver<Response<String>>(observer) {
    @Override public void onSuccess(Response<String> value) {
      throw e;
    }
  });

  assertThat(pluginRef.get()).isSameAs(e);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:SingleThrowingTest.java

示例12: resultThrowingInOnSuccessDeliveredToPlugin

import rx.exceptions.Exceptions; //導入依賴的package包/類
@Test public void resultThrowingInOnSuccessDeliveredToPlugin() {
  server.enqueue(new MockResponse());

  final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
  RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
    @Override public void handleError(Throwable throwable) {
      if (!pluginRef.compareAndSet(null, throwable)) {
        throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
      }
    }
  });

  RecordingSubscriber<Result<String>> observer = subscriberRule.create();
  final RuntimeException e = new RuntimeException();
  service.result().subscribe(new ForwardingObserver<Result<String>>(observer) {
    @Override public void onSuccess(Result<String> value) {
      throw e;
    }
  });

  assertThat(pluginRef.get()).isSameAs(e);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:SingleThrowingTest.java

示例13: bodyThrowingInOnCompleteDeliveredToPlugin

import rx.exceptions.Exceptions; //導入依賴的package包/類
@Test public void bodyThrowingInOnCompleteDeliveredToPlugin() {
  server.enqueue(new MockResponse());

  final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
  RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
    @Override public void handleError(Throwable throwable) {
      if (throwable instanceof OnCompletedFailedException) {
        if (!pluginRef.compareAndSet(null, throwable)) {
          throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
        }
      }
    }
  });

  RecordingSubscriber<String> observer = subscriberRule.create();
  final RuntimeException e = new RuntimeException();
  service.body().subscribe(new ForwardingSubscriber<String>(observer) {
    @Override public void onCompleted() {
      throw e;
    }
  });

  observer.assertAnyValue();
  assertThat(pluginRef.get().getCause()).isSameAs(e);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:ObservableThrowingSafeSubscriberTest.java

示例14: responseThrowingInOnCompleteDeliveredToPlugin

import rx.exceptions.Exceptions; //導入依賴的package包/類
@Test public void responseThrowingInOnCompleteDeliveredToPlugin() {
  server.enqueue(new MockResponse());

  final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
  RxJavaPlugins.getInstance().registerErrorHandler(new RxJavaErrorHandler() {
    @Override public void handleError(Throwable throwable) {
      if (throwable instanceof OnCompletedFailedException) {
        if (!pluginRef.compareAndSet(null, throwable)) {
          throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
        }
      }
    }
  });

  RecordingSubscriber<Response<String>> observer = subscriberRule.create();
  final RuntimeException e = new RuntimeException();
  service.response().subscribe(new ForwardingSubscriber<Response<String>>(observer) {
    @Override public void onCompleted() {
      throw e;
    }
  });

  observer.assertAnyValue();
  assertThat(pluginRef.get().getCause()).isSameAs(e);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:ObservableThrowingSafeSubscriberTest.java

示例15: request

import rx.exceptions.Exceptions; //導入依賴的package包/類
public void request(long n) {
    if (n < 0) {
        throw new IllegalArgumentException("n >= 0 required");
    } else if (n != 0 && compareAndSet(false, true)) {
        Subscriber<? super T> c = this.child;
        T v = this.value;
        if (!c.isUnsubscribed()) {
            try {
                c.onNext(v);
                if (!c.isUnsubscribed()) {
                    c.onCompleted();
                }
            } catch (Throwable e) {
                Exceptions.throwOrReport(e, c, v);
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:19,代碼來源:SingleProducer.java


注:本文中的rx.exceptions.Exceptions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。