Promise<?> promise = Promise.async(f -> temp.collectList().subscribe(f::success, f::error)).transform(transformer); Flux next = Flux.create(subscriber -> promise.onError(subscriber::error).then(value -> { subscriber.next(value); subscriber.complete(); Promise<?> promise = Promise.async(f -> temp.subscribe(f::success, f::error)).transform(transformer); Mono next = Mono.create(subscriber -> promise.onError(subscriber::error).then(subscriber::success) ); result = recoveryFunction.onErrorResume(next);
/** * Specifies the action to take if the an error occurs trying to produce the promised value. * <p> * If the given action throws an exception, the original exception will be rethrown with the exception thrown * by the action added to the suppressed exceptions list. * * @param errorHandler the action to take if an error occurs * @return A promise for the successful result */ default Promise<T> onError(Action<? super Throwable> errorHandler) { return onError(Predicate.TRUE, errorHandler); }
/** * Convert this promise into a {@link CompletableFuture}. * <p> * @return a {@link CompletableFuture} that will complete successfully or exceptionally on the current execution thread. * @since 1.6 */ default CompletableFuture<T> toCompletableFuture() { CompletableFuture<T> future = new CompletableFuture<>(); onError(future::completeExceptionally).then(future::complete); return future; }
return onError(errorType::isInstance, t -> errorHandler.execute(errorType.cast(t)));
@Override public void subscribe(Subscriber<? super ByteBuf> s) { file .onError(s::onError) .then(channel -> s.onSubscribe(new ManagedSubscription<ByteBuf>(s, ByteBuf::release) {
@Override public void subscribe(Subscriber<? super T> subscriber) { this.promise.onError(subscriber::onError).then(i -> Streams.publish(i).subscribe(subscriber) ); }
promise.onError(subscriber::onError).then(subscriber::onSuccess) );
promise.onError(subscriber::error).then(subscriber::success) );
.onError(e -> { cancelled = true; s.cancel();
@Override public void onNext(I in) { if (done.get()) { return; } Promise<? extends O> out; try { out = function.apply(in); } catch (Throwable throwable) { subscription.cancel(); innerOnError(throwable); return; } out.onError(e -> { subscription.cancel(); innerOnError(e); }).then(v -> { if (!done.get()) { outSubscriber.onNext(v); } }); }
private void drainRequestBody(Consumer<Throwable> next) { if (requestBody == null || !requestBody.isUnread()) { next.accept(null); } else { if (Execution.isActive()) { Promise.async(down -> requestBody.drain(e -> { if (e == null) { down.success(null); } else { down.error(e); } }) ) .onError(next::accept) .then(n -> next.accept(null)); } else { requestBody.drain(next); } } }
promise.onError(subscriber::error).then(value -> { subscriber.next(value); subscriber.complete();
/** * Reduces the stream to a single composite byte buf. * * @param publisher the stream * @param alloc the buffer allocator * @return the reduced composite buffer */ public static Promise<CompositeByteBuf> compose(Publisher<? extends ByteBuf> publisher, ByteBufAllocator alloc) { return Promise.flatten(() -> { CompositeByteBuf seed = alloc.compositeBuffer(); return Streams.reduce(publisher, seed, (c, b) -> c.addComponent(true, b)) .onError(e -> { seed.release(); throw Exceptions.toException(e); }); }); }
up.connect(down.<T>onSuccess(value -> { try { transformer.apply(value).onError(down::error).then(down::success); } catch (Throwable e) { down.error(e);
Promise<?> promise = Promise.async(f -> temp.collectList().subscribe(f::success, f::error)).transform(transformer); Flux next = Flux.create(subscriber -> promise.onError(subscriber::error).then(value -> { subscriber.next(value); subscriber.complete(); Promise<?> promise = Promise.async(f -> temp.subscribe(f::success, f::error)).transform(transformer); Mono next = Mono.create(subscriber -> promise.onError(subscriber::error).then(subscriber::success) ); result = recoveryFunction.onErrorResume(next);
sessionData.remove(Pac4jSessionKeys.REQUESTED_URL); return originalUrl; }).onError(t -> { if (t instanceof RequiresHttpAction) { webContext.sendResponse((RequiresHttpAction) t);