[Gradle, JS] Useful message on exception for webpack
#KT-38286 fixed
This commit is contained in:
+4
-5
@@ -75,13 +75,14 @@ internal fun Project.execWithErrorLogger(description: String, body: (ExecAction)
|
|||||||
body(exec)
|
body(exec)
|
||||||
return project!!.operation(description) {
|
return project!!.operation(description) {
|
||||||
progress(description)
|
progress(description)
|
||||||
|
val client = TeamCityMessageCommonClient(logger, this)
|
||||||
exec.standardOutput = TCServiceMessageOutputStreamHandler(
|
exec.standardOutput = TCServiceMessageOutputStreamHandler(
|
||||||
client = TeamCityMessageCommonClient(logger, this),
|
client = client,
|
||||||
onException = { },
|
onException = { },
|
||||||
logger = logger
|
logger = logger
|
||||||
)
|
)
|
||||||
exec.errorOutput = TCServiceMessageOutputStreamHandler(
|
exec.errorOutput = TCServiceMessageOutputStreamHandler(
|
||||||
client = TeamCityMessageCommonClient(logger, this),
|
client = client,
|
||||||
onException = { },
|
onException = { },
|
||||||
logger = logger
|
logger = logger
|
||||||
)
|
)
|
||||||
@@ -89,9 +90,7 @@ internal fun Project.execWithErrorLogger(description: String, body: (ExecAction)
|
|||||||
val result = exec.execute()
|
val result = exec.execute()
|
||||||
if (result.exitValue != 0) {
|
if (result.exitValue != 0) {
|
||||||
error(
|
error(
|
||||||
"""
|
client.testFailedMessage()
|
||||||
Process '$description' returns ${result.exitValue}
|
|
||||||
""".trimIndent()
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
|
|||||||
+12
@@ -10,6 +10,7 @@ import jetbrains.buildServer.messages.serviceMessages.ServiceMessage
|
|||||||
import jetbrains.buildServer.messages.serviceMessages.ServiceMessageParserCallback
|
import jetbrains.buildServer.messages.serviceMessages.ServiceMessageParserCallback
|
||||||
import org.gradle.api.logging.Logger
|
import org.gradle.api.logging.Logger
|
||||||
import org.gradle.internal.logging.progress.ProgressLogger
|
import org.gradle.internal.logging.progress.ProgressLogger
|
||||||
|
import org.jetbrains.kotlin.gradle.utils.clearAnsiColor
|
||||||
import java.text.ParseException
|
import java.text.ParseException
|
||||||
|
|
||||||
class TeamCityMessageCommonClient(
|
class TeamCityMessageCommonClient(
|
||||||
@@ -17,6 +18,8 @@ class TeamCityMessageCommonClient(
|
|||||||
private val progressLogger: ProgressLogger
|
private val progressLogger: ProgressLogger
|
||||||
) : ServiceMessageParserCallback {
|
) : ServiceMessageParserCallback {
|
||||||
|
|
||||||
|
private val errors = mutableListOf<String>()
|
||||||
|
|
||||||
private val stackTraceProcessor = TeamCityMessageStackTraceProcessor()
|
private val stackTraceProcessor = TeamCityMessageStackTraceProcessor()
|
||||||
|
|
||||||
override fun parseException(e: ParseException, text: String) {
|
override fun parseException(e: ParseException, text: String) {
|
||||||
@@ -29,6 +32,11 @@ class TeamCityMessageCommonClient(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun testFailedMessage(): String {
|
||||||
|
return errors
|
||||||
|
.joinToString("\n")
|
||||||
|
}
|
||||||
|
|
||||||
private fun printMessage(text: String, type: String?) {
|
private fun printMessage(text: String, type: String?) {
|
||||||
val value = text.trimEnd()
|
val value = text.trimEnd()
|
||||||
progressLogger.progress(value)
|
progressLogger.progress(value)
|
||||||
@@ -41,6 +49,10 @@ class TeamCityMessageCommonClient(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
when (actualType) {
|
||||||
|
ERROR, WARN -> errors.add(value.clearAnsiColor())
|
||||||
|
}
|
||||||
|
|
||||||
actualType?.let { log.processLogMessage(value, it) }
|
actualType?.let { log.processLogMessage(value, it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user