@@ -87,17 +87,18 @@ public actual interface Job : CoroutineContext.Element {
87
87
public actual val isCancelled: Boolean
88
88
89
89
/* *
90
- * Returns [CancellationException] that signals the completion of this job.
90
+ * Returns [CancellationException] that signals the completion of this job. This function is
91
+ * used by [cancellable][suspendCancellableCoroutine] suspending functions. They throw exception
92
+ * returned by this function when they suspend in the context of this job and this job becomes _complete_.
91
93
*
92
- * It returns the original [cancel] cause if it is an instance of [CancellationException] or
93
- * an instance of [JobCancellationException] if this job was cancelled with a cause of
94
- * different type, was cancelled without a cause or had completed normally.
94
+ * This function returns the original [cancel] cause of this job if that `cause` was an instance of
95
+ * [CancellationException]. Otherwise (if this job was cancelled with a cause of a different type, or
96
+ * was cancelled without a cause, or had completed normally), an instance of [JobCancellationException] is
97
+ * returned. The [JobCancellationException.cause] of the resulting [JobCancellationException] references
98
+ * the original cancellation cause that was passed to [cancel] function.
95
99
*
96
- * This function throws [IllegalStateException] when invoked for an job that has not
100
+ * This function throws [IllegalStateException] when invoked on a job that has not
97
101
* [completed][isCompleted] nor [cancelled][isCancelled] yet.
98
- *
99
- * The [cancellable][suspendCancellableCoroutine] suspending functions throw this exception
100
- * when trying to suspend in the context of this job.
101
102
*/
102
103
public actual fun getCancellationException (): CancellationException
103
104
@@ -255,7 +256,8 @@ public actual interface DisposableHandle {
255
256
* This exception gets thrown if an exception is caught while processing [CompletionHandler] invocation for [Job].
256
257
*/
257
258
public actual class CompletionHandlerException public actual constructor(
258
- message : String , cause : Throwable
259
+ message : String ,
260
+ public override val cause : Throwable
259
261
) : RuntimeException(message.withCause(cause))
260
262
261
263
public actual open class CancellationException actual constructor(message : String ) : IllegalStateException(message)
@@ -267,7 +269,7 @@ public actual open class CancellationException actual constructor(message: Strin
267
269
*/
268
270
public actual class JobCancellationException public actual constructor(
269
271
message : String ,
270
- cause : Throwable ? ,
272
+ public override val cause : Throwable ? ,
271
273
/* *
272
274
* The job that was cancelled.
273
275
*/
0 commit comments