arrow-fx-coroutines / arrow.fx.coroutines.stream / handleErrorWith
fun <O, R>
Pull
<O, R>.handleErrorWith(f: (
Throwable
) ->
Pull
<O, R>):
Pull
<O, R>
fun <O>
Stream
<O>.handleErrorWith(h: (
Throwable
) ->
Stream
<O>):
Stream
<O>
If this
Stream terminates with Stream.raiseError`, invoke h and continue with result.
import arrow.fx.coroutines.stream.*
//sampleStart
suspend fun main(): Unit =
Stream(1, 2, 3)
.append { Stream.raiseError(RuntimeException()) }
.handleErrorWith { _: Throwable -> Stream.just(0) }
.toList()
.let(::println) // [1, 2, 3, 0]
//sampleEnd
Do you like Arrow?
✖