use of org.jetbrains.kotlin.cli.common.repl.ReplEvalResult in project beakerx by twosigma.
the class KotlinCodeRunner method call.
@Override
public TryResult call() throws Exception {
TryResult either;
ClassLoader oldld = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(loader);
InternalVariable.setValue(theOutput);
try {
theOutput.setOutputHandler();
InternalVariable.setValue(theOutput);
ReplEvalResult eval = repl.eval(this.codeToBeExecuted);
either = interpretResult(eval);
} catch (Throwable e) {
if (e instanceof InvocationTargetException)
e = ((InvocationTargetException) e).getTargetException();
if ((e instanceof InterruptedException) || (e instanceof ThreadDeath)) {
either = TryResult.createError(INTERUPTED_MSG);
} else {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
either = TryResult.createError(sw.toString());
}
} finally {
theOutput.clrOutputHandler();
Thread.currentThread().setContextClassLoader(oldld);
}
return either;
}
Aggregations