https://kotlinlang.org logo
Title
u

ursus

03/24/2021, 2:06 PM
So.. is it safe to use
runCatching
in coroutines for control flow? I gather it will catch CancelationException as well. Won't that break stuff?
👍 1
e

Erik

03/24/2021, 8:25 PM
It depends, but in general I wouldn't use it, because you'll also catch
CancellationException
, which you usually don't want to catch by default
See an interesting discussion here: https://github.com/Kotlin/kotlinx.coroutines/issues/1814 I commented there too, because I had the same question as you and I did some more research
d

diego-gomez-olvera

10/26/2021, 10:22 AM
is there any recommended alternative to
runCatching
that re-throws
CancellationException
?
d

diego-gomez-olvera

10/28/2021, 9:46 AM
that is what I had in mind, I was wondering if there was some ‘standard’, but I can just write it and use it in my project. Thanks!
🙂 1