Norbi
03/07/2023, 9:26 AMRaise<E>
?
I've just caught CancellationExceptionNoTrace
which seems to be an implementation detail of the raise mechanism...simon.vergauwen
03/07/2023, 9:26 AMCancellationException
in KotlinKristian Nedrevold
03/07/2023, 9:27 AMphldavies
03/07/2023, 9:36 AM.nonFatalOrThrow()
will rethrow anything you shouldn’t really be catchingNorbi
03/07/2023, 9:38 AMYou should never catchSure, I do it very rarely, eg. when intentionally catching ain KotlinCancellationException
TimeoutCancellationException
.
What I forgot was that the raise mechanism is also implemented using coroutines - sorry for the dumb question 😕 🙂
Thanks, I have to le-learn many things to get used to the "Kotlin/FP" thinking :).nonFatalOrThrow()
simon.vergauwen
03/07/2023, 9:52 AMcatch
or Either.catch
then you don't have to care about nonFatalOrThrow()
. If you're using try/catch
it might be interesting to use yourself instead of manually checking if(e is CancellationException) throw e
.
I personally prefer withTimeoutOrNull
instead of withTimeout
and try/catch(e: TimeoutCancellationException)
btw.runCatching
also swallows CancellationException
and doesn't re-throw it.Norbi
03/07/2023, 9:55 AM