REPL: Fix crash on trying to :load with incorrect filename (KT-12037)
(cherry picked from commit 0238575a36beec36c412862ded8abcad02ab4c1f)
This commit is contained in:
committed by
Yan Zhulanow
parent
a25e93d82a
commit
46c2adda4e
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.cli.jvm.repl.messages.unescapeLineBreaks
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.PrintWriter
|
||||
import java.util.*
|
||||
import java.util.concurrent.Callable
|
||||
@@ -140,8 +141,12 @@ class ReplFromTerminal(
|
||||
}
|
||||
else if (split.size >= 2 && split[0] == "load") {
|
||||
val fileName = split[1]
|
||||
val scriptText = FileUtil.loadFile(File(fileName))
|
||||
eval(scriptText)
|
||||
try {
|
||||
val scriptText = FileUtil.loadFile(File(fileName))
|
||||
eval(scriptText)
|
||||
} catch (e: IOException) {
|
||||
writer.outputCompileError("Can not load script: ${e.message}")
|
||||
}
|
||||
return true
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user