• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3  */
4 
5 package kotlinx.coroutines
6 
7 /**
8  * Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled while it is suspending.
9  * It indicates _normal_ cancellation of a coroutine.
10  * **It is not printed to console/log by default uncaught exception handler**.
11  * (see [CoroutineExceptionHandler]).
12  */
13 public actual typealias CancellationException = kotlin.coroutines.cancellation.CancellationException
14 
15 /**
16  * Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled or completed
17  * without cause, or with a cause or exception that is not [CancellationException]
18  * (see [Job.getCancellationException]).
19  */
20 internal actual class JobCancellationException public actual constructor(
21     message: String,
22     cause: Throwable?,
23     internal actual val job: Job
24 ) : CancellationException(message, cause) {
toStringnull25     override fun toString(): String = "${super.toString()}; job=$job"
26     override fun equals(other: Any?): Boolean =
27         other === this ||
28             other is JobCancellationException && other.message == message && other.job == job && other.cause == cause
29     override fun hashCode(): Int =
30         (message!!.hashCode() * 31 + job.hashCode()) * 31 + (cause?.hashCode() ?: 0)
31 }
32 
33 @Suppress("NOTHING_TO_INLINE")
34 internal actual inline fun Throwable.addSuppressedThrowable(other: Throwable) { /* empty */ }
35 
36 // For use in tests
37 internal actual val RECOVER_STACK_TRACES: Boolean = false
38