44
55package kotlinx.coroutines
66
7- /* *
8- * This exception gets thrown if an exception is caught while processing [CompletionHandler] invocation for [Job].
9- *
10- * @suppress **This an internal API and should not be used from general code.**
11- */
12- @InternalCoroutinesApi
13- public actual class CompletionHandlerException public actual constructor(
14- message : String ,
15- public override val cause : Throwable
16- ) : RuntimeException(message.withCause(cause))
17-
187/* *
198 * Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled while it is suspending.
209 * It indicates _normal_ cancellation of a coroutine.
2110 * **It is not printed to console/log by default uncaught exception handler**.
2211 * (see [CoroutineExceptionHandler]).
2312 */
24- public actual open class CancellationException actual constructor(message : String? ) : IllegalStateException(message)
25-
26- /* *
27- * Creates a cancellation exception with a specified message and [cause].
28- */
29- @Suppress(" FunctionName" )
30- public actual fun CancellationException (message : String? , cause : Throwable ? ) : CancellationException =
31- CancellationException (message.withCause(cause))
13+ public actual open class CancellationException (
14+ message : String? ,
15+ cause : Throwable ?
16+ ) : IllegalStateException(message, cause) {
17+ actual constructor (message: String? ) : this (message, null )
18+ }
3219
3320/* *
3421 * Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled or completed
@@ -37,9 +24,9 @@ public actual fun CancellationException(message: String?, cause: Throwable?) : C
3724 */
3825internal actual class JobCancellationException public actual constructor(
3926 message : String ,
40- public override val cause : Throwable ? ,
27+ cause : Throwable ? ,
4128 internal actual val job : Job
42- ) : CancellationException(message.withCause( cause) ) {
29+ ) : CancellationException(message, cause) {
4330 override fun toString (): String = " ${super .toString()} ; job=$job "
4431 override fun equals (other : Any? ): Boolean =
4532 other == = this ||
@@ -48,17 +35,6 @@ internal actual class JobCancellationException public actual constructor(
4835 (message!! .hashCode() * 31 + job.hashCode()) * 31 + (cause?.hashCode() ? : 0 )
4936}
5037
51- @Suppress(" FunctionName" )
52- internal fun IllegalStateException (message : String , cause : Throwable ? ) =
53- IllegalStateException (message.withCause(cause))
54-
55- private fun String?.withCause (cause : Throwable ? ) =
56- when {
57- cause == null -> this
58- this == null -> " caused by $cause "
59- else -> " $this ; caused by $cause "
60- }
61-
6238@Suppress(" NOTHING_TO_INLINE" )
6339internal actual inline fun Throwable.addSuppressedThrowable (other : Throwable ) { /* empty */ }
6440
0 commit comments