Skip to content

Commit 879881e

Browse files
authored
Fixed CoroutinesScope.ensureActive docs (#2242)
This is leftover from #2044 fix. Fixes #2241
1 parent fe2fedc commit 879881e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kotlinx-coroutines-core/common/src/CoroutineScope.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,19 @@ public fun CoroutineScope.cancel(message: String, cause: Throwable? = null): Uni
226226

227227
/**
228228
* Ensures that current scope is [active][CoroutineScope.isActive].
229-
* Throws [IllegalStateException] if the context does not have a job in it.
230229
*
231230
* If the job is no longer active, throws [CancellationException].
232231
* If the job was cancelled, thrown exception contains the original cancellation cause.
232+
* This function does not do anything if there is no [Job] in the scope's [coroutineContext][CoroutineScope.coroutineContext].
233233
*
234234
* This method is a drop-in replacement for the following code, but with more precise exception:
235235
* ```
236236
* if (!isActive) {
237237
* throw CancellationException()
238238
* }
239239
* ```
240+
*
241+
* @see CoroutineContext.ensureActive
240242
*/
241243
public fun CoroutineScope.ensureActive(): Unit = coroutineContext.ensureActive()
242244

0 commit comments

Comments
 (0)