Skip to content

Commit

Permalink
Better diagnostic exception message in MissingMainCoroutineDispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
qwwdfsad committed Dec 10, 2019
1 parent c02648b commit 6cb317b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/common/src/internal/Scopes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ internal open class ScopeCoroutine<in T>(
internal class ContextScope(context: CoroutineContext) : CoroutineScope {
override val coroutineContext: CoroutineContext = context
// CoroutineScope is used intentionally for user-friendly representation
override fun toString(): String = "CoroutineScope(coroutineContext = $coroutineContext)"
override fun toString(): String = "CoroutineScope(coroutineContext=$coroutineContext)"
}
3 changes: 2 additions & 1 deletion kotlinx-coroutines-core/jvm/src/internal/MainDispatchers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ private class MissingMainCoroutineDispatcher(
if (cause == null) {
throw IllegalStateException(
"Module with the Main dispatcher is missing. " +
"Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android'"
"Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android' " +
"and ensure it has the same version as 'kotlinx-coroutines-core'"
)
} else {
val message = "Module with the Main dispatcher had failed to initialize" + (errorHint?.let { ". $it" } ?: "")
Expand Down

0 comments on commit 6cb317b

Please sign in to comment.