@@ -18,6 +18,7 @@ import com.coder.gateway.sdk.TemplateIconDownloader
18
18
import com.coder.gateway.sdk.ex.AuthenticationResponseException
19
19
import com.coder.gateway.sdk.ex.TemplateResponseException
20
20
import com.coder.gateway.sdk.ex.WorkspaceResponseException
21
+ import com.coder.gateway.sdk.isCancellation
21
22
import com.coder.gateway.sdk.toURL
22
23
import com.coder.gateway.sdk.v2.models.WorkspaceStatus
23
24
import com.coder.gateway.sdk.v2.models.toAgentModels
@@ -424,11 +425,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
424
425
425
426
// Authenticate and load in a background process with progress.
426
427
// TODO: Make this cancelable.
427
- return LifetimeDefinition ().launchUnderBackgroundProgress(
428
- CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.cli.downloader.dialog.title" ),
429
- canBeCancelled = false ,
430
- isIndeterminate = true
431
- ) {
428
+ return LifetimeDefinition ().launchUnderBackgroundProgress(CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.cli.downloader.dialog.title" )) {
432
429
try {
433
430
this .indicator.text = " Authenticating client..."
434
431
authenticate(deploymentURL, token.first)
@@ -456,51 +453,55 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
456
453
tableOfWorkspaces.setEmptyState(CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.connect.text.connected" , deploymentURL.host))
457
454
tfUrlComment?.text = CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.connect.text.connected" , deploymentURL.host)
458
455
} catch (e: Exception ) {
459
- val reason = e.message ? : CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.no-reason" )
460
- val msg = when (e) {
461
- is java.nio.file.AccessDeniedException -> CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.access-denied" , e.file)
462
- is UnknownHostException -> CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.unknown-host" , e.message ? : deploymentURL.host)
463
- is InvalidExitValueException -> CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.unexpected-exit" , e.exitValue)
464
- is AuthenticationResponseException -> {
465
- CoderGatewayBundle .message(
466
- " gateway.connector.view.workspaces.connect.unauthorized" ,
467
- deploymentURL,
468
- )
469
- }
470
- is SocketTimeoutException -> {
471
- CoderGatewayBundle .message(
472
- " gateway.connector.view.workspaces.connect.timeout" ,
473
- deploymentURL,
474
- )
475
- }
476
- is ResponseException , is ConnectException -> {
477
- CoderGatewayBundle .message(
478
- " gateway.connector.view.workspaces.connect.download-failed" ,
479
- reason,
480
- )
456
+ if (isCancellation(e)) {
457
+ CoderRemoteConnectionHandle .logger.info(" Connection canceled due to ${e.javaClass.simpleName} " )
458
+ } else {
459
+ val reason = e.message ? : CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.no-reason" )
460
+ val msg = when (e) {
461
+ is java.nio.file.AccessDeniedException -> CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.access-denied" , e.file)
462
+ is UnknownHostException -> CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.unknown-host" , e.message ? : deploymentURL.host)
463
+ is InvalidExitValueException -> CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.unexpected-exit" , e.exitValue)
464
+ is AuthenticationResponseException -> {
465
+ CoderGatewayBundle .message(
466
+ " gateway.connector.view.workspaces.connect.unauthorized" ,
467
+ deploymentURL,
468
+ )
469
+ }
470
+ is SocketTimeoutException -> {
471
+ CoderGatewayBundle .message(
472
+ " gateway.connector.view.workspaces.connect.timeout" ,
473
+ deploymentURL,
474
+ )
475
+ }
476
+ is ResponseException , is ConnectException -> {
477
+ CoderGatewayBundle .message(
478
+ " gateway.connector.view.workspaces.connect.download-failed" ,
479
+ reason,
480
+ )
481
+ }
482
+ is SSLHandshakeException -> {
483
+ CoderGatewayBundle .message(
484
+ " gateway.connector.view.workspaces.connect.ssl-error" ,
485
+ deploymentURL.host,
486
+ reason,
487
+ )
488
+ }
489
+ else -> reason
481
490
}
482
- is SSLHandshakeException -> {
483
- CoderGatewayBundle .message(
484
- " gateway.connector.view.workspaces.connect.ssl-error" ,
485
- deploymentURL.host,
486
- reason,
487
- )
491
+ // It would be nice to place messages directly into the table
492
+ // but it does not support wrapping or markup so place it in the
493
+ // comment field of the URL input instead.
494
+ tfUrlComment?.foreground = UIUtil .getErrorForeground()
495
+ tfUrlComment?.text = msg
496
+ tableOfWorkspaces.setEmptyState(CoderGatewayBundle .message(
497
+ " gateway.connector.view.workspaces.connect.failed" ,
498
+ deploymentURL.host,
499
+ ))
500
+ logger.error(msg, e)
501
+
502
+ if (e is AuthenticationResponseException ) {
503
+ cs.launch { onAuthFailure?.invoke() }
488
504
}
489
- else -> reason
490
- }
491
- // It would be nice to place messages directly into the table
492
- // but it does not support wrapping or markup so place it in the
493
- // comment field of the URL input instead.
494
- tfUrlComment?.foreground = UIUtil .getErrorForeground()
495
- tfUrlComment?.text = msg
496
- tableOfWorkspaces.setEmptyState(CoderGatewayBundle .message(
497
- " gateway.connector.view.workspaces.connect.failed" ,
498
- deploymentURL.host,
499
- ))
500
- logger.error(msg, e)
501
-
502
- if (e is AuthenticationResponseException ) {
503
- cs.launch { onAuthFailure?.invoke() }
504
505
}
505
506
}
506
507
}
0 commit comments