Skip to content

Commit 44ebdef

Browse files
authored
Use cancellation exception from standard library in Kotlin/JS and K/N (#2638)
* On JVM it uses java.util.concurrent.CancellationException, same as stdlib declaration * Fully backwards compatible for JVM, Native-friendly for Obj-C interop
1 parent 99b4758 commit 44ebdef

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

kotlinx-coroutines-core/common/test/flow/internal/FlowScopeTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ class FlowScopeTest : TestBase() {
6868
flowScope {
6969
flowScope {
7070
launch {
71-
throw CancellationException(null)
71+
throw CancellationException("")
7272
}
7373
}
7474
}
7575
}
7676
}
77-
}
77+
}

kotlinx-coroutines-core/js/src/Exceptions.kt

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ package kotlinx.coroutines
1010
* **It is not printed to console/log by default uncaught exception handler**.
1111
* (see [CoroutineExceptionHandler]).
1212
*/
13-
public actual open class CancellationException(
14-
message: String?,
15-
cause: Throwable?
16-
) : IllegalStateException(message, cause) {
17-
public actual constructor(message: String?) : this(message, null)
18-
}
13+
public actual typealias CancellationException = kotlin.coroutines.cancellation.CancellationException
1914

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

kotlinx-coroutines-core/native/src/Exceptions.kt

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ package kotlinx.coroutines
1010
* **It is not printed to console/log by default uncaught exception handler**.
1111
* (see [CoroutineExceptionHandler]).
1212
*/
13-
public actual open class CancellationException(
14-
message: String?,
15-
cause: Throwable?
16-
) : IllegalStateException(message, cause) {
17-
public actual constructor(message: String?) : this(message, null)
18-
}
13+
public actual typealias CancellationException = kotlin.coroutines.cancellation.CancellationException
1914

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

0 commit comments

Comments
 (0)