Skip to content

Commit

Permalink
Use cancellation exception from standard library in Kotlin/JS and K/N (
Browse files Browse the repository at this point in the history
…Kotlin#2638)


* On JVM it uses java.util.concurrent.CancellationException, same as stdlib declaration
* Fully backwards compatible for JVM, Native-friendly for Obj-C interop
  • Loading branch information
qwwdfsad authored and pablobaxter committed Sep 14, 2022
1 parent d66076a commit 0d2a87b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
Expand Up @@ -68,10 +68,10 @@ class FlowScopeTest : TestBase() {
flowScope {
flowScope {
launch {
throw CancellationException(null)
throw CancellationException("")
}
}
}
}
}
}
}
7 changes: 1 addition & 6 deletions kotlinx-coroutines-core/js/src/Exceptions.kt
Expand Up @@ -10,12 +10,7 @@ package kotlinx.coroutines
* **It is not printed to console/log by default uncaught exception handler**.
* (see [CoroutineExceptionHandler]).
*/
public actual open class CancellationException(
message: String?,
cause: Throwable?
) : IllegalStateException(message, cause) {
public actual constructor(message: String?) : this(message, null)
}
public actual typealias CancellationException = kotlin.coroutines.cancellation.CancellationException

/**
* Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled or completed
Expand Down
7 changes: 1 addition & 6 deletions kotlinx-coroutines-core/native/src/Exceptions.kt
Expand Up @@ -10,12 +10,7 @@ package kotlinx.coroutines
* **It is not printed to console/log by default uncaught exception handler**.
* (see [CoroutineExceptionHandler]).
*/
public actual open class CancellationException(
message: String?,
cause: Throwable?
) : IllegalStateException(message, cause) {
public actual constructor(message: String?) : this(message, null)
}
public actual typealias CancellationException = kotlin.coroutines.cancellation.CancellationException

/**
* Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled or completed
Expand Down

0 comments on commit 0d2a87b

Please sign in to comment.