As in title I am calling firstOrNull in flow object. Below logs printed in iOS.
kotlinx.coroutines.flow.internal.AbortFlowException: Flow was aborted, no more elements needed
at 0 KMP Base Module.debug.dylib 0x107f01173 kfun:kotlin.Throwable#<init>(kotlin.String?){} + 119
at 1 KMP Base Module.debug.dylib 0x107efa63b kfun:kotlin.Exception#<init>(kotlin.String?){} + 115
at 2 KMP Base Module.debug.dylib 0x107efa85b kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 115
at 3 KMP Base Module.debug.dylib 0x107efad73 kfun:kotlin.IllegalStateException#<init>(kotlin.String?){} + 115
at 4 KMP Base Module.debug.dylib 0x107f08783 kfun:kotlin.coroutines.cancellation.CancellationException#<init>(kotlin.String?){} + 115
at 5 KMP Base Module.debug.dylib 0x10817c1a3 kfun:kotlinx.coroutines.flow.internal.AbortFlowException#<init>(kotlin.Any){} + 95
at 6 KMP Base Module.debug.dylib 0x10814d65f kfun:kotlinx.coroutines.flow.object-52.emit#internal + 279
at 7 KMP Base Module.debug.dylib 0x108188997 kfun:kotlinx.coroutines.flow.FlowCollector#emit#suspend(1:0;kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any-trampoline + 115
at 8 KMP Base Module.debug.dylib 0x10817c7a7 kfun:kotlinx.coroutines.flow.internal.SafeCollector#emit#suspend(1:0;kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any + 431
at 9 KMP Base Module.debug.dylib 0x108188997 kfun:kotlinx.coroutines.flow.FlowCollector#emit#suspend(1:0;kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any-trampoline + 115
at 10 KMP Base Module.debug.dylib 0x1075e875b kfun:com.easymoneycorp.kmpbasemodule.network.ApiService.$updateTodo$lambda$4$lambda$3COROUTINE$1.invokeSuspend#internal + 2635
at 11 KMP Base Module.debug.dylib 0x108040db7 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any?-trampoline + 71
at 12 KMP Base Module.debug.dylib 0x107f06aeb kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 647
at 13 KMP Base Module.debug.dylib 0x108040ea3 kfun:kotlin.coroutines.Continuation#resumeWith(kotlin.Result<1:0>){}-trampoline + 99
at 14 KMP Base Module.debug.dylib 0x108154953 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 1895
at 15 KMP Base Module.debug.dylib 0x10818462f kfun:kotlinx.coroutines.Runnable#run(){}-trampoline + 91
at 16 KMP Base Module.debug.dylib 0x10817f09b kfun:kotlinx.coroutines.DarwinGlobalQueueDispatcher.dispatch$lambda$0#internal + 119
at 17 KMP Base Module.debug.dylib 0x10817f0f7 kfun:kotlinx.coroutines.DarwinGlobalQueueDispatcher.$dispatch$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 71
at 18 KMP Base Module.debug.dylib 0x10817f1c7 kfun:kotlinx.coroutines.DarwinGlobalQueueDispatcher.$dispatch$lambda$0$FUNCTION_REFERENCE$0.$<bridge-DNN>invoke(){}#internal + 71
at 19 KMP Base Module.debug.dylib 0x10803e12b kfun:kotlin.Function0#invoke(){}1:0-trampoline + 99
at 20 KMP Base Module.debug.dylib 0x108180e23 _6f72672e6a6574627261696e732e6b6f746c696e783a6b6f746c696e782d636f726f7574696e65732d636f72652f6f70742f6275696c644167656e742f776f726b2f343465633665383530643563363366302f6b6f746c696e782d636f726f7574696e65732d636f72652f6e617469766544617277696e2f7372632f44697370617463686572732e6b74_knbridge8 + 203
at 21 libdispatch.dylib 0x1801774eb _dispatch_call_block_and_release + 23
at 22 libdispatch.dylib 0x180178ddf _dispatch_client_callout + 15
at 23 libdispatch.dylib 0x18017c337 _dispatch_queue_override_invoke + 1379
at 24 libdispatch.dylib 0x18018b517 _dispatch_root_queue_drain + 363
at 25 libdispatch.dylib 0x18018bf5f _dispatch_worker_thread2 + 231
at 26 libsystem_pthread.dylib 0x104867b37 _pthread_wqthread + 223
at 27 libsystem_pthread.dylib 0x104866933 start_wqthread + 7
When I inspected the source code its like below code. I just wonder am I doing something wrong? I don’t wanna see this exception log in logCat.
val collector = object : FlowCollector<T> {
override suspend fun emit(value: T) {
// Note: we are checking predicate first, then throw. If the predicate does suspend (calls emit, for example)
// the resulting code is never tail-suspending and produces a state-machine
if (!predicate(value)) {
throw AbortFlowException(this)
}
}
}
try {
collect(collector)
} catch (e: AbortFlowException) {
e.checkOwnership(collector)
}
New contributor
Mobile Dev is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1