@@ -161,25 +161,38 @@ class CoderRemoteConnectionHandle {
161
161
)
162
162
logger.info(" Adding ${parameters.ideName} for ${parameters.hostname} :${parameters.projectPath} to recent connections" )
163
163
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
+ )
164
170
} catch (e: Exception ) {
165
171
if (isCancellation(e)) {
166
172
logger.info(" Connection canceled due to ${e.javaClass.simpleName} " )
167
173
} else {
168
174
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
+ )
178
179
}
179
180
}
180
181
}
181
182
}
182
183
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
+
183
196
/* *
184
197
* Return a new (non-EAP) IDE if we should update.
185
198
*/
@@ -521,6 +534,7 @@ class CoderRemoteConnectionHandle {
521
534
522
535
companion object {
523
536
val logger = Logger .getInstance(CoderRemoteConnectionHandle ::class .java.simpleName)
537
+ @Throws(CoderSetupCommandException ::class )
524
538
fun processSetupCommand (
525
539
ignoreSetupFailure : Boolean ,
526
540
execCommand : () -> String
@@ -533,11 +547,11 @@ class CoderRemoteConnectionHandle {
533
547
?.let { it.substring(it.indexOf(GATEWAY_SETUP_COMMAND_ERROR ) + GATEWAY_SETUP_COMMAND_ERROR .length).trim() }
534
548
535
549
if (! errorText.isNullOrBlank()) {
536
- throw Exception (errorText)
550
+ throw CoderSetupCommandException (errorText)
537
551
}
538
552
} catch (ex: Exception ) {
539
553
if (! ignoreSetupFailure) {
540
- throw ex
554
+ throw CoderSetupCommandException (ex.message ? : " Unknown error " , ex)
541
555
}
542
556
}
543
557
}
0 commit comments