Thiyagu
01/02/2020, 2:01 PMonErrorContinue
in kotlin flow?Dominaezzz
01/02/2020, 2:11 PMThiyagu
01/02/2020, 2:24 PMfun main() = runBlocking {
val ints = flow {
// flow builder
for (i in 1..10) {
delay(100)
emit(i) // emit next value
}
}
ints.map {
if (it == 5) throw IllegalArgumentException("throwing exception")
it * 2
}.catch {
println("caught exception") // if any exception, don't process the next operator in the pipeline and continue the next subsequent element in the flow.
}.collect {
println("received $it")
}
}
Dominaezzz
01/02/2020, 2:25 PMThiyagu
01/02/2020, 2:28 PM