Skip to content

Commit 6cb317b

Browse files
committed
Better diagnostic exception message in MissingMainCoroutineDispatcher
1 parent c02648b commit 6cb317b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

kotlinx-coroutines-core/common/src/internal/Scopes.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ internal open class ScopeCoroutine<in T>(
3636
internal class ContextScope(context: CoroutineContext) : CoroutineScope {
3737
override val coroutineContext: CoroutineContext = context
3838
// CoroutineScope is used intentionally for user-friendly representation
39-
override fun toString(): String = "CoroutineScope(coroutineContext = $coroutineContext)"
39+
override fun toString(): String = "CoroutineScope(coroutineContext=$coroutineContext)"
4040
}

kotlinx-coroutines-core/jvm/src/internal/MainDispatchers.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ private class MissingMainCoroutineDispatcher(
8989
if (cause == null) {
9090
throw IllegalStateException(
9191
"Module with the Main dispatcher is missing. " +
92-
"Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android'"
92+
"Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android' " +
93+
"and ensure it has the same version as 'kotlinx-coroutines-core'"
9394
)
9495
} else {
9596
val message = "Module with the Main dispatcher had failed to initialize" + (errorHint?.let { ". $it" } ?: "")

0 commit comments

Comments
 (0)