catchAndEmitLast

fun <T> Flow<T>.catchAndEmitLast(f: FlowCollector<T>.(Throwable) -> T): Flow<T>

Catches exceptions that occur while collecting the flow and emits the result of the provided function f with the caught exception as a parameter.

Return

A Flow that emits the original flow's values and the result of the f function in case of an exception.

Parameters

f

A function that takes a FlowCollector and a Throwable and returns a value of type T.