Skip to content

Commit 9832d3d

Browse files
committed
Rephrased Job.getCancellationException docs for clarity
1 parent 13bb6d4 commit 9832d3d

File tree

1 file changed

+9
-8
lines changed
  • core/kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental

1 file changed

+9
-8
lines changed

core/kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/Job.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,18 @@ public interface Job : CoroutineContext.Element {
137137
public val isCancelled: Boolean
138138

139139
/**
140-
* Returns [CancellationException] that signals the completion of this job.
140+
* Returns [CancellationException] that signals the completion of this job. This function is
141+
* used by [cancellable][suspendCancellableCoroutine] suspending functions. They throw exception
142+
* returned by this function when they suspend in the context of this job and this job becomes _complete_.
141143
*
142-
* It returns the original [cancel] cause if it is an instance of [CancellationException] or
143-
* an instance of [JobCancellationException] if this job was cancelled with a cause of
144-
* different type, was cancelled without a cause or had completed normally.
144+
* This function returns the original [cancel] cause of this job if that `cause` was an instance of
145+
* [CancellationException]. Otherwise (if this job was cancelled with a cause of a different type, or
146+
* was cancelled without a cause, or had completed normally), an instance of [JobCancellationException] is
147+
* returned. The [JobCancellationException.cause] of the resulting [JobCancellationException] references
148+
* the original cancellation cause that was passed to [cancel] function.
145149
*
146-
* This function throws [IllegalStateException] when invoked for an job that has not
150+
* This function throws [IllegalStateException] when invoked on a job that has not
147151
* [completed][isCompleted] nor [cancelled][isCancelled] yet.
148-
*
149-
* The [cancellable][suspendCancellableCoroutine] suspending functions throw this exception
150-
* when trying to suspend in the context of this job.
151152
*/
152153
public fun getCancellationException(): CancellationException
153154

0 commit comments

Comments
 (0)