Properly handle REPL snippets with exceptions ...
so the REPL remain operational after exception in one of the snippets: - separately return script class and script instance on evaluation ( because in case of an exception the class is valid, while the instance is not). - store both the class and the instance in the history - handle this data accordingly
This commit is contained in:
+3
-3
@@ -41,11 +41,11 @@ open class BasicJvmScriptEvaluator : ScriptEvaluator {
|
||||
|
||||
compiledScript.resultField?.let { (resultFieldName, resultType) ->
|
||||
val resultField = scriptClass.java.getDeclaredField(resultFieldName).apply { isAccessible = true }
|
||||
ResultValue.Value(resultFieldName, resultField.get(instance), resultType.typeName, instance)
|
||||
} ?: ResultValue.Unit(instance)
|
||||
ResultValue.Value(resultFieldName, resultField.get(instance), resultType.typeName, scriptClass, instance)
|
||||
} ?: ResultValue.Unit(scriptClass, instance)
|
||||
|
||||
} catch (e: InvocationTargetException) {
|
||||
ResultValue.Error(e.targetException ?: e, e)
|
||||
ResultValue.Error(e.targetException ?: e, e, scriptClass)
|
||||
}
|
||||
|
||||
EvaluationResult(resultValue, refinedEvalConfiguration).let {
|
||||
|
||||
Reference in New Issue
Block a user