collectCatching

suspend fun <T> Flow<T>.collectCatching(collector: FlowCollector<T> = FlowCollector { }): Result<Unit>

The collectCatching function collects the elements emitted by the current Flow in a suspending way and returns a Result instance that represents the result of the operation.

If the collection of elements completes successfully, the function returns a Result instance with a value of Unit. Otherwise, it returns a Result instance with the corresponding error.