Skip to content

Commit 8cd1721

Browse files
vlegchilkinintellij-monorepo-bot
authored andcommitted
[python] catch ServerRuntimeException from target SDKs
* Docker client throws it when docker agent is not available for example. GitOrigin-RevId: 4e3a06467423ecbb0862beb5a7f8c692181855c9
1 parent 5e2028d commit 8cd1721

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

python/python-exec-service/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jvm_library(
4040
"//platform/projectModel-api:projectModel",
4141
"//libraries/kotlinx/serialization/json",
4242
"//libraries/kotlinx/serialization/core",
43+
"//platform/remote-servers/impl",
4344
]
4445
)
4546

@@ -74,6 +75,7 @@ jvm_library(
7475
"//platform/projectModel-api:projectModel",
7576
"//libraries/kotlinx/serialization/json",
7677
"//libraries/kotlinx/serialization/core",
78+
"//platform/remote-servers/impl",
7779
]
7880
)
7981
### auto-generated section `build intellij.python.community.execService` end

python/python-exec-service/intellij.python.community.execService.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@
5151
<orderEntry type="module" module-name="intellij.platform.projectModel" />
5252
<orderEntry type="module" module-name="intellij.libraries.kotlinx.serialization.json" />
5353
<orderEntry type="module" module-name="intellij.libraries.kotlinx.serialization.core" />
54+
<orderEntry type="module" module-name="intellij.platform.remoteServers.impl" />
5455
</component>
5556
</module>

python/python-exec-service/src/com/intellij/python/community/execService/impl/processLaunchers/targets.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import kotlinx.coroutines.CoroutineScope
2222
import kotlinx.coroutines.Dispatchers
2323
import kotlinx.coroutines.delay
2424
import kotlinx.coroutines.withContext
25+
import com.intellij.remoteServer.util.ServerRuntimeException
2526
import kotlin.io.path.pathString
2627
import kotlin.time.Duration.Companion.milliseconds
2728

@@ -32,7 +33,12 @@ internal suspend fun createProcessLauncherOnTarget(binOnTarget: BinOnTarget, lau
3233

3334
val request = if (target != null) {
3435
val projectMan = ProjectManager.getInstance() // Broken Targets API doesn't work without project
35-
target.createEnvironmentRequest(projectMan.openProjects.firstOrNull() ?: projectMan.defaultProject)
36+
try {
37+
target.createEnvironmentRequest(projectMan.openProjects.firstOrNull() ?: projectMan.defaultProject)
38+
}
39+
catch (e: ServerRuntimeException) {
40+
return@withContext Result.failure(ExecuteGetProcessError.EnvironmentError(MessageError(e.localizedMessage)))
41+
}
3642
}
3743
else LocalTargetEnvironmentRequest()
3844

0 commit comments

Comments
 (0)