https://kotlinlang.org logo
#coroutines
Title
# coroutines
u

ursus

08/18/2021, 11:55 AM
In crashlytics I'm seeing bunch of caught exceptions like this
Copy code
Non-fatal Exception: kotlinx.coroutines.flow.internal.ChildCancelledException: Child of the scoped flow was cancelled

Non-fatal Exception: kotlinx.coroutines.JobCancellationException: Job was cancelled
and no stacktrace; are there supposed to be ignored?
l

louiscad

08/18/2021, 3:24 PM
You're likely catching all
Exception
or `Throwable`s in a suspending function.
u

ursus

08/18/2021, 3:33 PM
yes, to map it into a Either monad thing
l

louiscad

08/18/2021, 3:34 PM
You should ignore
CancellationException
subclasses.
u

ursus

08/18/2021, 3:34 PM
Btw I noticed this during development in
flatMapLatest
mostly
you're saying it's natural?
m

Marcelo Hernandez

08/19/2021, 9:10 AM
In order for Coroutines to properly cancel,
CancellationException
must not be swallowed.
It needs to be thrown.
u

ursus

08/19/2021, 11:46 AM
its just logged,
.onCompletion { t -> if (t != null) log(t) }
thanks for you help!
21 Views