![JAR search and dependency download from the Maven repository](/logo.png)
ratpack.rx2.internal.ExecutionBackedSubscriber Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ratpack-rx2 Show documentation
Show all versions of ratpack-rx2 Show documentation
Ratpack kotlin dsl library
The newest version!
package ratpack.rx2.internal;
import io.reactivex.FlowableSubscriber;
import io.reactivex.exceptions.CompositeException;
import io.reactivex.exceptions.OnErrorNotImplementedException;
import io.reactivex.exceptions.UndeliverableException;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import ratpack.exec.Promise;
import ratpack.func.Action;
public class ExecutionBackedSubscriber implements FlowableSubscriber {
private final Subscriber super T> subscriber;
public ExecutionBackedSubscriber(Subscriber subscriber) {
this.subscriber = subscriber;
}
@Override
public void onComplete() {
try {
subscriber.onComplete();
} catch (final OnErrorNotImplementedException e) {
Promise.error(e.getCause()).then(Action.noop());
} catch (Exception e) {
Promise.error(new UndeliverableException(e)).then(Action.noop());
}
}
@Override
public void onError(Throwable e) {
try {
subscriber.onError(e);
} catch (final OnErrorNotImplementedException e2) {
Promise.error(e2.getCause()).then(Action.noop());
} catch (Exception e2) {
Promise.error(new CompositeException(e, e2)).then(Action.noop());
}
}
@Override
public void onSubscribe(Subscription s) {
try {
subscriber.onSubscribe(s);
} catch (final OnErrorNotImplementedException e) {
Promise.error(e.getCause()).then(Action.noop());
} catch (Exception e) {
Promise.error(new UndeliverableException(e)).then(Action.noop());
}
}
@Override
public void onNext(T t) {
try {
subscriber.onNext(t);
} catch (final OnErrorNotImplementedException e) {
Promise.error(e.getCause()).then(Action.noop());
} catch (Exception e) {
Promise.error(new UndeliverableException(e)).then(Action.noop());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy