Skip to content
Discussion options

You must be logged in to vote

Hey @404-,

Thank you for your interest, and this is actually a great question!

It's not explicitly mentioned anywhere in the documentation, but perhaps it should! So Kotlin(X) Coroutines requires CancellationException to cancel a running coroutine, so for raise to properly work in the Kotlin ecosystem we're required to use CancellationException. (There are other implementation possible for Raise without using exceptions, but they don't cooperate nicely with other Coroutine code).

However there is no performance impact, since stacktrace creation is disabled. So the performance impact you're referring to comes from stacktrace creation, which occurs on construction of any subclass of Throwable

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kyay10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants