本文整理了Java中rx.subjects.Subject.onError()
方法的一些代码示例,展示了Subject.onError()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Subject.onError()
方法的具体详情如下:
包路径:rx.subjects.Subject
类名称:Subject
方法名:onError
暂无
代码示例来源:origin: akarnokd/RxJava2Interop
@Override
public void onError(Throwable e) {
if (!terminated) {
if (e == null) {
e = new NullPointerException("Throwable was null");
}
error = e;
terminated = true;
source.onError(e);
} else {
io.reactivex.plugins.RxJavaPlugins.onError(e);
}
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Override
public void onError(Throwable e) {
if (!terminated) {
if (e == null) {
e = new NullPointerException("Throwable was null");
}
error = e;
terminated = true;
source.onError(e);
} else {
io.reactivex.plugins.RxJavaPlugins.onError(e);
}
}
代码示例来源:origin: com.netflix.eureka/eureka2-core
@Override
public void onError(Throwable e) {
if (isCompleted.compareAndSet(false, true)) {
ackSubject.onError(e);
}
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj2ToSj1Error() {
io.reactivex.subjects.PublishSubject<Integer> ps2 = io.reactivex.subjects.PublishSubject.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(ps2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test();
assertTrue(sj1.hasObservers());
assertTrue(ps2.hasObservers());
sj1.onError(new IOException());
assertFalse(sj1.hasObservers());
assertFalse(ps2.hasObservers());
to.assertFailure(IOException.class);
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public void fail(final Throwable throwable) {
observable.onError(throwable);
if (span != null) {
Map<String, Object> exData = new HashMap<String, Object>();
exData.put(Fields.ERROR_KIND, "Exception");
exData.put(Fields.ERROR_OBJECT, throwable);
exData.put(Fields.EVENT, "failed");
exData.put(Fields.MESSAGE, throwable.getMessage());
span.log(exData);
}
}
代码示例来源:origin: com.netflix.eureka/eureka2-core
@Override
public final void close(Throwable error) {
_close();
lifecycle.onError(error);
}
代码示例来源:origin: com.netflix.eureka/eureka2-core
private void terminateLifecycle(Throwable e) {
if (e == null) {
lifecycleSubject.onCompleted();
} else {
lifecycleSubject.onError(e);
}
}
代码示例来源:origin: ru.yandex.cocaine/cocaine-client
public void onError(long id, ServiceException exception) {
Session session = sessions.remove(id);
if (session != null) {
logger.debug("Setting error " + exception.getMessage() + " for session " + id);
session.input.onError(exception);
} else {
logger.warn("Session " + id + " does not exist");
}
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public void call() {
try {
observable.onError(err);
} catch (Exception ex) {
LOGGER.warn("Caught exception while onError on observable", ex);
}
}
});
代码示例来源:origin: couchbase/couchbase-jvm-core
@Override
public void onNext(LifecycleState lifecycleState) {
if (lifecycleState == LifecycleState.DISCONNECTED) {
request.observable().onError(new CouchbaseException("Could not connect endpoint."));
}
}
});
代码示例来源:origin: com.couchbase.client/core-io
@Override
public void onNext(LifecycleState lifecycleState) {
if (lifecycleState == LifecycleState.DISCONNECTED) {
request.observable().onError(new CouchbaseException("Could not connect endpoint."));
}
}
});
代码示例来源:origin: com.netflix.eureka/eureka2-client
@Override
public Observable<Void> shutdown(Throwable cause) {
remoteBatchingRegistry.shutdown();
relay.onError(cause);
return Observable.empty();
}
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public void call() {
try {
observable.onError(err);
} catch (Exception ex) {
LOGGER.warn("Caught exception while onError on observable", ex);
} finally {
worker.unsubscribe();
}
}
});
代码示例来源:origin: com.couchbase.client/core-io
@Override
public void onNext(LifecycleState lifecycleState) {
if (lifecycleState == LifecycleState.DISCONNECTED) {
request.observable().onError(new CouchbaseException("Could not connect storedEndpoint."));
}
}
});
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj2ToSj1Lifecycle() {
io.reactivex.subjects.PublishSubject<Integer> pp2 = io.reactivex.subjects.PublishSubject.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(pp2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test(0L);
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasObservers());
sj1.onNext(1);
sj1.onError(new IOException());
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasObservers());
assertFalse(pp2.hasComplete());
assertTrue(pp2.hasThrowable());
assertNotNull(pp2.getThrowable());
to.assertFailure(rx.exceptions.MissingBackpressureException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void fp2ToSj1Error() {
io.reactivex.processors.FlowableProcessor<Integer> pp2 = io.reactivex.processors.PublishProcessor.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(pp2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test();
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasSubscribers());
sj1.onError(new IOException());
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasSubscribers());
assertFalse(pp2.hasComplete());
assertTrue(pp2.hasThrowable());
assertNotNull(pp2.getThrowable());
assertTrue(pp2.getThrowable() instanceof IOException);
to.assertFailure(IOException.class);
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public void call() {
try {
obs.onNext(response);
obs.onCompleted();
} catch(Exception ex) {
obs.onError(ex);
} finally {
worker.unsubscribe();
}
}
});
代码示例来源:origin: com.couchbase.client/core-io
/**
* Always retry the request and send it into the response buffer.
*
* @param request the request to retry
* @param responseBuffer the response buffer to send it into.
*/
public static void retry(final CouchbaseRequest request, final EventSink<ResponseEvent> responseBuffer) {
if(!responseBuffer.tryPublishEvent(ResponseHandler.RESPONSE_TRANSLATOR, request, request.observable())) {
request.observable().onError(CouchbaseCore.BACKPRESSURE_EXCEPTION);
}
}
}
代码示例来源:origin: couchbase/couchbase-jvm-core
/**
* Always retry the request and send it into the response buffer.
*
* @param request the request to retry
* @param responseBuffer the response buffer to send it into.
*/
public static void retry(final CouchbaseRequest request, final EventSink<ResponseEvent> responseBuffer) {
if(!responseBuffer.tryPublishEvent(ResponseHandler.RESPONSE_TRANSLATOR, request, request.observable())) {
request.observable().onError(CouchbaseCore.BACKPRESSURE_EXCEPTION);
}
}
}
代码示例来源:origin: yahoo/fili
/**
* Handle publishing the length and an error to the Subject.
*
* @param stream Stream to get the length from
* @param t Error that was encountered (to be published)
*/
private void emitError(LengthOfOutputStream stream, Throwable t) {
Subject<Long, Long> lengthBroadcaster = stream.getLengthBroadcaster();
lengthBroadcaster.onNext(stream.getResponseLength());
lengthBroadcaster.onError(t);
}
内容来源于网络,如有侵权,请联系作者删除!