martmists
12/08/2023, 1:48 PMkotlinx.coroutines.CancellationException
or kotlin.coroutines.cancellation.CancellationException
? on JVM they're both linked to the same thing, but I don't know about other platforms and/or what the most "future-proof" version is.Joffrey
12/08/2023, 1:52 PMkotlinx.coroutines.CancellationException
is an alias of kotlin.coroutines.cancellation.CancellationException
. You can see it in their KDocs:
https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-cancellation-exception/martmists
12/08/2023, 1:54 PMkotlin.coroutines.cancellation.CancellationException
? I feel like having it duplicated might lead to confusionJoffrey
12/08/2023, 2:03 PMkotlin.coroutines
package from the stdlib (not kotlinX
) contains the primitives for the core language support of coroutines, so I'm not sure why they needed to represent cancellation there. I guess if you're using the kotlinx.coroutines library it makes sense to use the kotlinx CancellationException
. I would also be happy to understand more if someone knows 🙂Joffrey
12/08/2023, 2:05 PMDmitry Khalanskiy [JB]
12/08/2023, 2:10 PMCancellationException
is useful often enough that adding a separate kotlin.coroutines.cancellation
import just for it would cumulatively add a lot of useless noise.Joffrey
12/08/2023, 2:11 PMDmitry Khalanskiy [JB]
12/08/2023, 2:17 PMCancellationException
because it has to highlight the definitions exported to Objective-C as throwing a CancellationException
. Otherwise, Objective-C thinks of such exceptions as unexpected failures and crashes.