From 57b24007ac89e2cb3bb6b25ff15beb06853f5826 Mon Sep 17 00:00:00 2001 From: Natalia Selezneva Date: Tue, 8 May 2018 16:18:15 +0300 Subject: [PATCH] Log exceptions thrown during Run Scratch Action --- .../idea/scratch/actions/RunScratchAction.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/RunScratchAction.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/RunScratchAction.kt index 7753d7f5911..57e5a35d9e9 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/RunScratchAction.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/RunScratchAction.kt @@ -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.printDebugMessage import org.jetbrains.kotlin.idea.scratch.ui.ScratchTopPanel +import org.jetbrains.kotlin.idea.scratch.LOG as log class RunScratchAction(private val scratchPanel: ScratchTopPanel) : AnAction( KotlinBundle.message("scratch.run.button"), @@ -45,7 +46,7 @@ class RunScratchAction(private val scratchPanel: ScratchTopPanel) : AnAction( 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() 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) {