I have this Android Kotlin code with a list of completables that are merged into a bigger one with mergeDelayError()
, that has a timeout. When the timeout is reached, I get java.util.concurrent.TimeoutException: The source did not signal an event for 250 milliseconds and has been terminated.
How can I tell which one of the small completables on the list reached the timeout without signaling/emitting anything (the actual list has more than two BTW). My ideal solution would replace such exception with something like: Exception: The following operations reached a timeout: Check initial settings, Check server
, or at least an specific log line printed out by each timed-out completable.
I have no idea how to do this. My first guess would be simply adding a "didEmit" flag to each completable and check them one by one when the timeout is reached on the big completable, but it seems like a bad solution to me.
Any ideas appreciated. Thank you.
val smallCompletable1 = controller
.checkInitialSettings()
.doOnError {
logError(it)
}
.ignoreElement()
val smallCompletable2 = controller
.checkServerStatus()
.doOnError {
logError(it)
}
.ignoreElement()
val myCompletables: List<Completable> = listOf(
smallCompletable1,
smallCompletable2
)
val bigDisposable = Completable
.mergeDelayError(myCompletables)
.timeout(250, TimeUnit.MILLISECONDS)
.subscribe(this::handleAllSucceeded, this::handleError)
composition.add(bigDisposable)