Log exceptions thrown during Run Scratch Action

This commit is contained in:
Natalia Selezneva
2018-05-08 16:18:15 +03:00
parent 5148a51ea2
commit 57b24007ac
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.idea.scratch.ScratchFileLanguageProvider
import org.jetbrains.kotlin.idea.scratch.output.ScratchOutputHandlerAdapter import org.jetbrains.kotlin.idea.scratch.output.ScratchOutputHandlerAdapter
import org.jetbrains.kotlin.idea.scratch.printDebugMessage import org.jetbrains.kotlin.idea.scratch.printDebugMessage
import org.jetbrains.kotlin.idea.scratch.ui.ScratchTopPanel import org.jetbrains.kotlin.idea.scratch.ui.ScratchTopPanel
import org.jetbrains.kotlin.idea.scratch.LOG as log
class RunScratchAction(private val scratchPanel: ScratchTopPanel) : AnAction( class RunScratchAction(private val scratchPanel: ScratchTopPanel) : AnAction(
KotlinBundle.message("scratch.run.button"), KotlinBundle.message("scratch.run.button"),
@@ -45,7 +46,7 @@ class RunScratchAction(private val scratchPanel: ScratchTopPanel) : AnAction(
val handler = provider.getOutputHandler() val handler = provider.getOutputHandler()
org.jetbrains.kotlin.idea.scratch.LOG.printDebugMessage("Run Action: isMakeBeforeRun = $isMakeBeforeRun, isRepl = $isRepl") log.printDebugMessage("Run Action: isMakeBeforeRun = $isMakeBeforeRun, isRepl = $isRepl")
val module = scratchPanel.getModule() val module = scratchPanel.getModule()
if (module == null) { if (module == null) {
@@ -72,7 +73,16 @@ class RunScratchAction(private val scratchPanel: ScratchTopPanel) : AnAction(
} }
}) })
executor.execute() try {
executor.execute()
} catch (ex: Throwable) {
handler.error(scratchFile, "Exception occurs during Run Scratch Action")
handler.onFinish(scratchFile)
e.presentation.isEnabled = true
log.error(ex)
}
} }
if (isMakeBeforeRun) { if (isMakeBeforeRun) {