@@ -161,25 +161,38 @@ class CoderRemoteConnectionHandle {
161161 )
162162 logger.info(" Adding ${parameters.ideName} for ${parameters.hostname} :${parameters.projectPath} to recent connections" )
163163 recentConnectionsService.addRecentConnection(parameters.toRecentWorkspaceConnection())
164+ } catch (e: CoderSetupCommandException ) {
165+ logger.error(" Failed to run setup command" , e)
166+ showConnectionErrorMessage(
167+ e.message ? : " Unknown error" ,
168+ " gateway.connector.coder.setup-command.failed" ,
169+ )
164170 } catch (e: Exception ) {
165171 if (isCancellation(e)) {
166172 logger.info(" Connection canceled due to ${e.javaClass.simpleName} " )
167173 } else {
168174 logger.error(" Failed to connect (will not retry)" , e)
169- // The dialog will close once we return so write the error
170- // out into a new dialog.
171- ApplicationManager .getApplication().invokeAndWait {
172- Messages .showMessageDialog(
173- e.message ? : e.javaClass.simpleName ? : " Aborted" ,
174- CoderGatewayBundle .message(" gateway.connector.coder.connection.failed" ),
175- Messages .getErrorIcon(),
176- )
177- }
175+ showConnectionErrorMessage(
176+ e.message ? : e.javaClass.simpleName ? : " Aborted" ,
177+ " gateway.connector.coder.connection.failed"
178+ )
178179 }
179180 }
180181 }
181182 }
182183
184+ // The dialog will close once we return so write the error
185+ // out into a new dialog.
186+ private fun showConnectionErrorMessage (message : String , titleKey : String ) {
187+ ApplicationManager .getApplication().invokeAndWait {
188+ Messages .showMessageDialog(
189+ message,
190+ CoderGatewayBundle .message(titleKey),
191+ Messages .getErrorIcon(),
192+ )
193+ }
194+ }
195+
183196 /* *
184197 * Return a new (non-EAP) IDE if we should update.
185198 */
@@ -521,6 +534,7 @@ class CoderRemoteConnectionHandle {
521534
522535 companion object {
523536 val logger = Logger .getInstance(CoderRemoteConnectionHandle ::class .java.simpleName)
537+ @Throws(CoderSetupCommandException ::class )
524538 fun processSetupCommand (
525539 ignoreSetupFailure : Boolean ,
526540 execCommand : () -> String
@@ -533,11 +547,11 @@ class CoderRemoteConnectionHandle {
533547 ?.let { it.substring(it.indexOf(GATEWAY_SETUP_COMMAND_ERROR ) + GATEWAY_SETUP_COMMAND_ERROR .length).trim() }
534548
535549 if (! errorText.isNullOrBlank()) {
536- throw Exception (errorText)
550+ throw CoderSetupCommandException (errorText)
537551 }
538552 } catch (ex: Exception ) {
539553 if (! ignoreSetupFailure) {
540- throw ex
554+ throw CoderSetupCommandException (ex.message ? : " Unknown error " , ex)
541555 }
542556 }
543557 }
0 commit comments