@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); } }
@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); } }
@Override public void onError(Throwable e) { if (isCompleted.compareAndSet(false, true)) { ackSubject.onError(e); } }
@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); }
@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); } }
@Override public final void close(Throwable error) { _close(); lifecycle.onError(error); }
private void terminateLifecycle(Throwable e) { if (e == null) { lifecycleSubject.onCompleted(); } else { lifecycleSubject.onError(e); } }
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"); } }
@Override public void call() { try { observable.onError(err); } catch (Exception ex) { LOGGER.warn("Caught exception while onError on observable", ex); } } });
@Override public void onNext(LifecycleState lifecycleState) { if (lifecycleState == LifecycleState.DISCONNECTED) { request.observable().onError(new CouchbaseException("Could not connect endpoint.")); } } });
@Override public void onNext(LifecycleState lifecycleState) { if (lifecycleState == LifecycleState.DISCONNECTED) { request.observable().onError(new CouchbaseException("Could not connect endpoint.")); } } });
@Override public Observable<Void> shutdown(Throwable cause) { remoteBatchingRegistry.shutdown(); relay.onError(cause); return Observable.empty(); } }
@Override public void call() { try { observable.onError(err); } catch (Exception ex) { LOGGER.warn("Caught exception while onError on observable", ex); } finally { worker.unsubscribe(); } } });
@Override public void onNext(LifecycleState lifecycleState) { if (lifecycleState == LifecycleState.DISCONNECTED) { request.observable().onError(new CouchbaseException("Could not connect storedEndpoint.")); } } });
@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); }
@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); }
@Override public void call() { try { obs.onNext(response); obs.onCompleted(); } catch(Exception ex) { obs.onError(ex); } finally { worker.unsubscribe(); } } });
/** * 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); } } }
/** * 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); } } }
/** * 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); }