4
4
5
5
package kotlinx.coroutines
6
6
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
-
18
7
/* *
19
8
* Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled while it is suspending.
20
9
* It indicates _normal_ cancellation of a coroutine.
21
10
* **It is not printed to console/log by default uncaught exception handler**.
22
11
* (see [CoroutineExceptionHandler]).
23
12
*/
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
+ }
32
19
33
20
/* *
34
21
* 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
37
24
*/
38
25
internal actual class JobCancellationException public actual constructor(
39
26
message : String ,
40
- public override val cause : Throwable ? ,
27
+ cause : Throwable ? ,
41
28
internal actual val job : Job
42
- ) : CancellationException(message.withCause( cause) ) {
29
+ ) : CancellationException(message, cause) {
43
30
override fun toString (): String = " ${super .toString()} ; job=$job "
44
31
override fun equals (other : Any? ): Boolean =
45
32
other == = this ||
@@ -48,17 +35,6 @@ internal actual class JobCancellationException public actual constructor(
48
35
(message!! .hashCode() * 31 + job.hashCode()) * 31 + (cause?.hashCode() ? : 0 )
49
36
}
50
37
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
-
62
38
@Suppress(" NOTHING_TO_INLINE" )
63
39
internal actual inline fun Throwable.addSuppressedThrowable (other : Throwable ) { /* empty */ }
64
40
0 commit comments