Python: ExecService API clean-up: it can only return ExecException, not PyError

GitOrigin-RevId: ca635cc7b5b639cb5d6434f7f360d6ddf1de0eb1
This commit is contained in:
Ilya.Kazakevich
2025-01-31 23:16:54 +00:00
committed by intellij-monorepo-bot
parent 8e677810e6
commit 1bb2332f0c
2 changed files with 5 additions and 5 deletions
@@ -5,7 +5,7 @@ import com.intellij.platform.eel.EelApi
import com.intellij.python.community.execService.impl.ExecServiceImpl
import com.jetbrains.python.PythonBinary
import com.jetbrains.python.Result
import com.jetbrains.python.errorProcessing.PyError
import com.jetbrains.python.errorProcessing.PyError.ExecException
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.annotations.CheckReturnValue
import org.jetbrains.annotations.Nls
@@ -28,7 +28,7 @@ interface ExecService {
*/
@ApiStatus.Internal
@CheckReturnValue
suspend fun execGetStdout(whatToExec: WhatToExec, args: List<String> = emptyList<String>(), processDescription: @Nls String? = null, timeout: Duration = 1.minutes): Result<String, PyError>
suspend fun execGetStdout(whatToExec: WhatToExec, args: List<String> = emptyList<String>(), processDescription: @Nls String? = null, timeout: Duration = 1.minutes): Result<String, ExecException>
}
sealed interface WhatToExec {
@@ -12,7 +12,7 @@ import com.intellij.python.community.execService.ExecService
import com.intellij.python.community.execService.WhatToExec
import com.jetbrains.python.PythonHelpersLocator
import com.jetbrains.python.Result
import com.jetbrains.python.errorProcessing.PyError
import com.jetbrains.python.errorProcessing.PyError.ExecException
import com.jetbrains.python.errorProcessing.failure
import com.jetbrains.python.execution.FailureReason
import com.jetbrains.python.execution.userMessage
@@ -25,7 +25,7 @@ import kotlin.time.Duration
internal object ExecServiceImpl : ExecService {
override suspend fun execGetStdout(whatToExec: WhatToExec, args: List<String>, processDescription: @Nls String?, timeout: Duration): Result<String, PyError> {
override suspend fun execGetStdout(whatToExec: WhatToExec, args: List<String>, processDescription: @Nls String?, timeout: Duration): Result<String, ExecException> {
val (eel, exe, args) = when (whatToExec) {
is WhatToExec.Binary -> Triple(whatToExec.binary.getEelDescriptor().upgrade(), whatToExec.binary.pathString, args)
is WhatToExec.Helper -> {
@@ -54,7 +54,7 @@ private suspend fun EelApi.execGetStdoutImpl(
args: List<String>,
processDescription: @Nls String,
timeout: Duration,
): Result<String, PyError> {
): Result<String, ExecException> {
val process = exec.executeProcess(exe, *args.toTypedArray()).getOr { err ->
val text = PyExecBundle.message("py.exec.start.error", processDescription, err.error.message, err.error.errno)
val failure = PyExecFailureImpl(exe, args, text, FailureReason.CantStart)