Skip to content

Commit 132c1e3

Browse files
committed
Rename DispatchException to CoroutinesInternalError and make it an Error to better reflect its semantics
1 parent 0c8789d commit 132c1e3

File tree

6 files changed

+6
-7
lines changed

6 files changed

+6
-7
lines changed

kotlinx-coroutines-core/common/src/Dispatched.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ internal abstract class DispatchedTask<in T>(
268268
}
269269

270270
val cause = exception ?: finallyException
271-
val reason = DispatchException("Fatal exception in coroutines machinery for $this. " +
271+
val reason = CoroutinesInternalError("Fatal exception in coroutines machinery for $this. " +
272272
"Please read KDoc to 'handleFatalException' method and report this incident to maintainers", cause!!)
273273
handleExceptionViaHandler(this.delegate.context, reason)
274274
}

kotlinx-coroutines-core/common/src/Exceptions.common.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ internal expect class JobCancellationException(
2323
internal val job: Job
2424
}
2525

26-
internal expect class DispatchException(message: String, cause: Throwable) : RuntimeException
26+
internal expect class CoroutinesInternalError(message: String, cause: Throwable) : Error
2727

2828
internal expect fun Throwable.addSuppressedThrowable(other: Throwable)
29-
3029
// For use in tests
3130
internal expect val RECOVER_STACK_TRACES: Boolean

kotlinx-coroutines-core/js/src/Exceptions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ internal actual class JobCancellationException public actual constructor(
4848
(message!!.hashCode() * 31 + job.hashCode()) * 31 + (cause?.hashCode() ?: 0)
4949
}
5050

51-
internal actual class DispatchException actual constructor(message: String, cause: Throwable) : RuntimeException(message.withCause(cause))
51+
internal actual class CoroutinesInternalError actual constructor(message: String, cause: Throwable) : Error(message.withCause(cause))
5252

5353
@Suppress("FunctionName")
5454
internal fun IllegalStateException(message: String, cause: Throwable?) =

kotlinx-coroutines-core/jvm/src/Exceptions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ internal actual class JobCancellationException public actual constructor(
8181
(message!!.hashCode() * 31 + job.hashCode()) * 31 + (cause?.hashCode() ?: 0)
8282
}
8383

84-
internal actual class DispatchException actual constructor(message: String, cause: Throwable) : RuntimeException(message, cause)
84+
internal actual class CoroutinesInternalError actual constructor(message: String, cause: Throwable) : Error(message, cause)
8585

8686
@Suppress("NOTHING_TO_INLINE")
8787
internal actual inline fun Throwable.addSuppressedThrowable(other: Throwable) =

kotlinx-coroutines-core/jvm/test/FailingCoroutinesMachineryTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class FailingCoroutinesMachineryTest(
127127
val e = caught
128128
assertNotNull(e)
129129
// First condition -- failure in context element
130-
val firstCondition = e is DispatchException && e.cause is TestException
130+
val firstCondition = e is CoroutinesInternalError && e.cause is TestException
131131
// Second condition -- failure from isDispatchNeeded (#880)
132132
val secondCondition = e is TestException
133133
assertTrue(firstCondition xor secondCondition)

kotlinx-coroutines-core/native/src/Exceptions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ internal actual class JobCancellationException public actual constructor(
4848
(message!!.hashCode() * 31 + job.hashCode()) * 31 + (cause?.hashCode() ?: 0)
4949
}
5050

51-
internal actual class DispatchException actual constructor(message: String, cause: Throwable) : RuntimeException(message.withCause(cause))
51+
internal actual class CoroutinesInternalError actual constructor(message: String, cause: Throwable) : Error(message.withCause(cause))
5252

5353
@Suppress("FunctionName")
5454
internal fun IllegalStateException(message: String, cause: Throwable?) =

0 commit comments

Comments
 (0)