Improve orx-olive

This commit is contained in:
Edwin Jakobs
2019-05-21 00:15:05 +02:00
parent b5db7998b7
commit ee4f424d9a
6 changed files with 91 additions and 34 deletions

View File

@@ -4,9 +4,9 @@ import java.io.InputStream
import java.io.Reader
import javax.script.ScriptEngineManager
class LoadException(message: String? = null, cause: Throwable? = null) : RuntimeException(message, cause)
internal class LoadException(message: String? = null, cause: Throwable? = null) : RuntimeException(message, cause)
class KtsObjectLoader(classLoader: ClassLoader? = Thread.currentThread().contextClassLoader) {
internal class KtsObjectLoader(classLoader: ClassLoader? = Thread.currentThread().contextClassLoader) {
val engine = ScriptEngineManager(classLoader).getEngineByExtension("kts")
@@ -17,10 +17,8 @@ class KtsObjectLoader(classLoader: ClassLoader? = Thread.currentThread().context
}
inline fun <R> safeEval(noinline evaluation: () -> R?) = try {
println(evaluation)
evaluation()
} catch (e: Exception) {
e.printStackTrace()
throw LoadException("Cannot load script", e)
}