Update MonoUtils.java

This commit is contained in:
Andrea Cavalli 2020-10-20 02:13:58 +02:00
parent 6fd5b099c3
commit cb1d0dfe3a

View File

@ -151,6 +151,14 @@ public class MonoUtils {
});
}
public static <T extends TdApi.Object> Mono<T> orElseLogSkipError(TdResult<T> optional) {
if (optional.failed()) {
logger.error("Received TDLib error: {}", optional.cause());
return Mono.empty();
}
return Mono.just(optional.result());
}
public static <T extends TdApi.Object> Mono<Void> thenOrLogRepeatError(Supplier<? extends Mono<TdResult<T>>> optionalMono) {
return Mono.defer(() -> optionalMono.get().handle((TdResult<T> optional, SynchronousSink<Void> sink) -> {
if (optional.succeeded()) {