Scripting: switch legacy CLI REPL to the new infrastructure
This commit is contained in:
@@ -57,8 +57,13 @@ class BasicJvmReplEvaluator(val scriptEvaluator: ScriptEvaluator = BasicJvmScrip
|
||||
}
|
||||
KJvmEvaluatedSnippet(snippetVal, currentConfiguration, retVal)
|
||||
}
|
||||
else ->
|
||||
KJvmEvaluatedSnippet(snippetVal, currentConfiguration, ResultValue.NotEvaluated)
|
||||
else -> {
|
||||
val firstError = evalRes.reports.find { it.isError() }
|
||||
KJvmEvaluatedSnippet(
|
||||
snippetVal, currentConfiguration,
|
||||
firstError?.exception?.let { ResultValue.Error(it) } ?: ResultValue.NotEvaluated
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val newNode = lastEvaluatedSnippet.add(newEvalRes)
|
||||
|
||||
+9
@@ -5,6 +5,7 @@
|
||||
|
||||
package kotlin.script.experimental.jvm.util
|
||||
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.PrintStream
|
||||
import kotlin.script.experimental.api.ResultValue
|
||||
|
||||
@@ -42,3 +43,11 @@ fun ResultValue.Error.renderError(stream: PrintStream) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun ResultValue.Error.renderError(): String =
|
||||
ByteArrayOutputStream().use { os ->
|
||||
val ps = PrintStream(os)
|
||||
renderError(ps)
|
||||
ps.flush()
|
||||
os.toString()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user