Skip to content

Commit ad50f82

Browse files
committed
Fix: report error if supported IDEs could not be resolved
- the IDEs combobox is no longer stuck with the text "Retrieving products.." if an exception happens in the code. - instead, exceptions are handled a new custom combo box renderer is installed that tells the user that an error was encountered while retrieving the IDEs. - resolves #10
1 parent 71ed51b commit ad50f82

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
lines changed

src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,24 +110,35 @@ class CoderLocateRemoteProjectStepView : CoderWorkspacesWizardStep, Disposable {
110110

111111
cs.launch {
112112
logger.info("Retrieving available IDE's for ${selectedWorkspace.name} workspace...")
113-
val workspaceOS = withContext(Dispatchers.IO) {
114-
RemoteCredentialsHolder().apply {
115-
setHost("coder.${selectedWorkspace.name}")
116-
userName = "coder"
117-
authType = AuthType.OPEN_SSH
118-
}.guessOs
119-
}
120-
logger.info("Resolved OS and Arch for ${selectedWorkspace.name} is: $workspaceOS")
121-
val idesWithStatus = IntelliJPlatformProduct.values()
122-
.filter { it.showInGateway }
123-
.flatMap { CachingProductsJsonWrapper.getAvailableIdes(it, workspaceOS) }
124-
.map { ide -> IdeWithStatus(ide.product, ide.buildNumber, IdeStatus.DOWNLOAD, ide.downloadLink, ide.presentableVersion) }
125-
126-
if (idesWithStatus.isEmpty()) {
127-
logger.warn("Could not resolve any IDE for workspace ${selectedWorkspace.name}, probably $workspaceOS is not supported by Gateway")
128-
} else {
129-
ideComboBoxModel.addAll(idesWithStatus)
130-
cbIDE.selectedIndex = 0
113+
try {
114+
val workspaceOS = withContext(Dispatchers.IO) {
115+
RemoteCredentialsHolder().apply {
116+
setHost("coder.${selectedWorkspace.name}")
117+
userName = "coder"
118+
authType = AuthType.OPEN_SSH
119+
}.guessOs
120+
}
121+
logger.info("Resolved OS and Arch for ${selectedWorkspace.name} is: $workspaceOS")
122+
val idesWithStatus = IntelliJPlatformProduct.values()
123+
.filter { it.showInGateway }
124+
.flatMap { CachingProductsJsonWrapper.getAvailableIdes(it, workspaceOS) }
125+
.map { ide -> IdeWithStatus(ide.product, ide.buildNumber, IdeStatus.DOWNLOAD, ide.downloadLink, ide.presentableVersion) }
126+
127+
if (idesWithStatus.isEmpty()) {
128+
logger.warn("Could not resolve any IDE for workspace ${selectedWorkspace.name}, probably $workspaceOS is not supported by Gateway")
129+
} else {
130+
ideComboBoxModel.addAll(idesWithStatus)
131+
cbIDE.selectedIndex = 0
132+
}
133+
} catch (e: Exception) {
134+
logger.error("Could not resolve any IDE for workspace ${selectedWorkspace.name}. Reason: $e")
135+
cbIDE.renderer = object : ColoredListCellRenderer<IdeWithStatus>() {
136+
override fun customizeCellRenderer(list: JList<out IdeWithStatus>, value: IdeWithStatus?, index: Int, isSelected: Boolean, cellHasFocus: Boolean) {
137+
background = UIUtil.getListBackground(isSelected, cellHasFocus)
138+
icon = UIUtil.getBalloonErrorIcon()
139+
append(CoderGatewayBundle.message("gateway.connector.view.coder.remoteproject.ide.error.text", selectedWorkspace.name))
140+
}
141+
}
131142
}
132143
}
133144
}

src/main/resources/messages/CoderGatewayBundle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ gateway.connector.view.login.cli.downloader.dialog.title=Authenticate and setup
1212
gateway.connector.view.coder.workspaces.next.text=Select IDE and Project
1313
gateway.connector.view.coder.workspaces.choose.text=Choose a workspace
1414
gateway.connector.view.coder.remoteproject.loading.text=Retrieving products...
15+
gateway.connector.view.coder.remoteproject.ide.error.text=Could not retrieve any IDE for workspace {0} because an error was encountered
1516
gateway.connector.view.coder.remoteproject.next.text=Download and Start IDE
1617
gateway.connector.view.coder.remoteproject.choose.text=Choose IDE and project for workspace {0}
1718
gateway.connector.recentconnections.title=Recent Coder Workspaces

0 commit comments

Comments
 (0)