Add original errors into the IllegalStateException from import of build script models

This exception is needed to finish gradle import and avoid importing other models into IDE
In most cases this exception is repoted together with Gradle exception from import,
but as soon as it it visible in UI we add some clarification which errors are happened
This commit is contained in:
Natalia Selezneva
2020-06-19 16:24:53 +03:00
parent 3afc37438e
commit 8bb3c0796d
@@ -63,19 +63,24 @@ fun processScriptModel(
}
}
if (models.containsErrors()) {
val errors = models.collectErrors()
if (errors.isNotEmpty()) {
if (sync != null) {
synchronized(sync) {
sync.failed = true
}
}
throw IllegalStateException(KotlinIdeaGradleBundle.message("title.kotlin.build.script"))
throw IllegalStateException(
KotlinIdeaGradleBundle.message("title.kotlin.build.script")
+ ":\n"
+ errors.joinToString("\n") { it.text + "\n" + it.details }
)
}
}
}
private fun Collection<KotlinDslScriptModel>.containsErrors(): Boolean {
return any { it.messages.any { it.severity == KotlinDslScriptModel.Severity.ERROR } }
private fun Collection<KotlinDslScriptModel>.collectErrors(): List<KotlinDslScriptModel.Message> {
return this.flatMap { it.messages.filter { it.severity == KotlinDslScriptModel.Severity.ERROR } }
}
private fun KotlinDslScriptsModel.toListOfScriptModels(project: Project): List<KotlinDslScriptModel> =