Skip to content

Commit 04060b4

Browse files
committed
PowerShellScriptCommandLineState: code cleanup, stop ignoring exceptions
1 parent 0b2484b commit 04060b4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/main/kotlin/com/intellij/plugin/powershell/ide/run/PowerShellScriptCommandLineState.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import com.intellij.execution.process.ProcessHandler
99
import com.intellij.execution.runners.ExecutionEnvironment
1010
import com.intellij.execution.util.ProgramParametersUtil
1111
import com.intellij.openapi.application.readAction
12-
import com.intellij.openapi.diagnostic.Logger
12+
import com.intellij.openapi.diagnostic.logger
1313
import com.intellij.openapi.roots.ProjectRootManager
1414
import com.intellij.openapi.util.text.StringUtil
1515
import com.intellij.openapi.vfs.LocalFileSystem
@@ -24,7 +24,6 @@ import kotlin.io.path.Path
2424

2525
class PowerShellScriptCommandLineState(private val runConfiguration: PowerShellRunConfiguration, environment: ExecutionEnvironment) :
2626
CommandLineState(environment), RunProfileState {
27-
private val LOG = Logger.getInstance("#" + javaClass.name)
2827

2928
lateinit var workingDirectory: Path
3029
suspend fun prepareExecution() {
@@ -52,12 +51,12 @@ class PowerShellScriptCommandLineState(private val runConfiguration: PowerShellR
5251
.withWorkDirectory(workingDirectory.toString())
5352

5453
runConfiguration.environmentVariables.configureCommandLine(commandLine, true)
55-
LOG.debug("Command line: $command")
56-
LOG.debug("Environment: " + commandLine.environment.toString())
57-
LOG.debug("Effective Environment: " + commandLine.effectiveEnvironment.toString())
54+
logger.debug("Command line: $command")
55+
logger.debug("Environment: " + commandLine.environment.toString())
56+
logger.debug("Effective Environment: " + commandLine.effectiveEnvironment.toString())
5857
return KillableColoredProcessHandler(commandLine)
5958
} catch (e: PowerShellNotInstalled) {
60-
LOG.warn("Can not start PowerShell: ${e.message}")
59+
logger.warn("Can not start PowerShell: ${e.message}")
6160
throw ExecutionException(e.message, e)
6261
}
6362
}
@@ -81,13 +80,16 @@ class PowerShellScriptCommandLineState(private val runConfiguration: PowerShellR
8180
val p = matcher.group(i)
8281
if (!StringUtil.isEmpty(p)) matchedParams.add(p)
8382
} catch (e: IllegalStateException) {
83+
logger.error(e)
8484
} catch (e: IndexOutOfBoundsException) {
85+
logger.error(e)
8586
}
86-
8787
}
8888
}
8989
commandString.addAll(matchedParams)
9090
}
9191
return commandString
9292
}
9393
}
94+
95+
private val logger = logger<PowerShellScriptCommandLineState>()

0 commit comments

Comments
 (0)